List of usage examples for com.fasterxml.jackson.annotation PropertyAccessor ALL
PropertyAccessor ALL
To view the source code for com.fasterxml.jackson.annotation PropertyAccessor ALL.
Click Source Link
From source file:de.ks.flatadocdb.index.GlobalIndex.java
protected ObjectMapper getMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.findAndRegisterModules();// w w w .j a v a 2 s .c o m mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); mapper.enableDefaultTyping(); mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT); return mapper; }
From source file:com.josue.tileset.editor.Editor.java
private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportBtnActionPerformed JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("Json file", "json")); String outputFileName = inputFile.getAbsolutePath().split("\\.")[0] + ".json"; fileDialog.setSelectedFile(new File(outputFileName)); if (fileDialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { File file = fileDialog.getSelectedFile(); ObjectMapper mapper = new ObjectMapper(); mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); try {/*from www.j a v a 2 s.c o m*/ mapper.writeValue(file, loadedTiles); } catch (IOException ex) { Logger.getLogger(Editor.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:org.geoserver.notification.geonode.GeoNodeJsonEncoder.java
@Override public byte[] encode(Notification notification) throws Exception { byte[] ret = null; ObjectMapper mapper = new ObjectMapper(); mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")); mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); mapper.setSerializationInclusion(Include.NON_NULL); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); KombuMessage message = new KombuMessage(); message.setId(new UID().toString()); message.setType(notification.getType() != null ? notification.getType().name() : null); message.setAction(notification.getAction() != null ? notification.getAction().name() : null); message.setTimestamp(new Date()); message.setUser(notification.getUser()); message.setOriginator(InetAddress.getLocalHost().getHostAddress()); message.setProperties(notification.getProperties()); if (notification.getObject() instanceof NamespaceInfo) { NamespaceInfo obj = (NamespaceInfo) notification.getObject(); KombuNamespaceInfo source = new KombuNamespaceInfo(); source.setId(obj.getId());/*w w w . ja v a 2 s. c om*/ source.setType("NamespaceInfo"); source.setName(obj.getName()); source.setNamespaceURI(obj.getURI()); message.setSource(source); } if (notification.getObject() instanceof WorkspaceInfo) { WorkspaceInfo obj = (WorkspaceInfo) notification.getObject(); KombuWorkspaceInfo source = new KombuWorkspaceInfo(); source.setId(obj.getId()); source.setType("WorkspaceInfo"); source.setName(obj.getName()); source.setNamespaceURI(""); message.setSource(source); } if (notification.getObject() instanceof LayerInfo) { LayerInfo obj = (LayerInfo) notification.getObject(); KombuLayerInfo source = new KombuLayerInfo(); source.setId(obj.getId()); source.setType("LayerInfo"); source.setName(obj.getName()); source.setResourceType(obj.getType() != null ? obj.getType().name() : ""); BeanToPropertyValueTransformer transformer = new BeanToPropertyValueTransformer("name"); Collection<String> styleNames = CollectionUtils.collect(obj.getStyles(), transformer); source.setStyles(StringUtils.join(styleNames.toArray())); source.setDefaultStyle(obj.getDefaultStyle() != null ? obj.getDefaultStyle().getName() : ""); ResourceInfo res = obj.getResource(); source.setWorkspace(res.getStore() != null ? res.getStore().getWorkspace() != null ? res.getStore().getWorkspace().getName() : "" : ""); if (res.getNativeBoundingBox() != null) { source.setBounds(new Bounds(res.getNativeBoundingBox())); } if (res.getLatLonBoundingBox() != null) { source.setGeographicBunds(new Bounds(res.getLatLonBoundingBox())); } message.setSource(source); } if (notification.getObject() instanceof LayerGroupInfo) { LayerGroupInfo obj = (LayerGroupInfo) notification.getObject(); KombuLayerGroupInfo source = new KombuLayerGroupInfo(); source.setId(obj.getId()); source.setType("LayerGroupInfo"); source.setName(obj.getName()); source.setWorkspace(obj.getWorkspace() != null ? obj.getWorkspace().getName() : ""); source.setMode(obj.getType().name()); String rootStyle = obj.getRootLayerStyle() != null ? obj.getRootLayerStyle().getName() : ""; source.setRootLayerStyle(rootStyle); source.setRootLayer(obj.getRootLayer() != null ? obj.getRootLayer().getPath() : ""); for (PublishedInfo pl : obj.getLayers()) { KombuLayerSimpleInfo kl = new KombuLayerSimpleInfo(); if (pl instanceof LayerInfo) { LayerInfo li = (LayerInfo) pl; kl.setName(li.getName()); String lstyle = li.getDefaultStyle() != null ? li.getDefaultStyle().getName() : ""; if (!lstyle.equals(rootStyle)) { kl.setStyle(lstyle); } source.addLayer(kl); } } message.setSource(source); } if (notification.getObject() instanceof ResourceInfo) { ResourceInfo obj = (ResourceInfo) notification.getObject(); KombuResourceInfo source = null; if (notification.getObject() instanceof FeatureTypeInfo) { source = new KombuFeatureTypeInfo(); source.setType("FeatureTypeInfo"); } if (notification.getObject() instanceof CoverageInfo) { source = new KombuCoverageInfo(); source.setType("CoverageInfo"); } if (notification.getObject() instanceof WMSLayerInfo) { source = new KombuWMSLayerInfo(); source.setType("WMSLayerInfo"); } if (source != null) { source.setId(obj.getId()); source.setName(obj.getName()); source.setWorkspace(obj.getStore() != null ? obj.getStore().getWorkspace() != null ? obj.getStore().getWorkspace().getName() : "" : ""); source.setNativeName(obj.getNativeName()); source.setStore(obj.getStore() != null ? obj.getStore().getName() : ""); if (obj.getNativeBoundingBox() != null) { source.setGeographicBunds(new Bounds(obj.getNativeBoundingBox())); } if (obj.boundingBox() != null) { source.setBounds(new Bounds(obj.boundingBox())); } } message.setSource(source); } if (notification.getObject() instanceof StoreInfo) { StoreInfo obj = (StoreInfo) notification.getObject(); KombuStoreInfo source = new KombuStoreInfo(); source.setId(obj.getId()); source.setType("StoreInfo"); source.setName(obj.getName()); source.setWorkspace(obj.getWorkspace() != null ? obj.getWorkspace().getName() : ""); message.setSource(source); } ret = mapper.writeValueAsBytes(message); return ret; }