private void addTagsToProperties(MethodInfo mi, JSONObject propJ) throws JSONException { // create description object. description tag enables the visual tools to display description of // keys/values // of a map property, items of a list, properties within a complex type. JSONObject descriptionObj = new JSONObject(); if (mi.comment != null) { descriptionObj.put("$", mi.comment); } for (Map.Entry<String, String> descEntry : mi.descriptions.entrySet()) { descriptionObj.put(descEntry.getKey(), descEntry.getValue()); } if (descriptionObj.length() > 0) { propJ.put("descriptions", descriptionObj); } // create useSchema object. useSchema tag is added to enable visual tools to be able to render a // text field // as a dropdown with choices populated from the schema attached to the port. JSONObject useSchemaObj = new JSONObject(); for (Map.Entry<String, String> useSchemaEntry : mi.useSchemas.entrySet()) { useSchemaObj.put(useSchemaEntry.getKey(), useSchemaEntry.getValue()); } if (useSchemaObj.length() > 0) { propJ.put("useSchema", useSchemaObj); } }
private JSONObject setFieldAttributes(String clazz, CompactFieldNode field) throws JSONException { JSONObject port = new JSONObject(); port.put("name", field.getName()); TypeGraphVertex tgv = typeGraph.getTypeGraphVertex(clazz); putFieldDescription(field, port, tgv); List<CompactAnnotationNode> annotations = field.getVisibleAnnotations(); CompactAnnotationNode firstAnnotation; if (annotations != null && !annotations.isEmpty() && (firstAnnotation = field.getVisibleAnnotations().get(0)) != null) { for (Map.Entry<String, Object> entry : firstAnnotation.getAnnotations().entrySet()) { port.put(entry.getKey(), entry.getValue()); } } return port; }