public Set<String> getOperatorClasses(String parent, String searchTerm) throws ClassNotFoundException { if (CollectionUtils.isEmpty(operatorClassNames)) { loadOperatorClass(); } if (parent == null) { parent = Operator.class.getName(); } else { if (!typeGraph.isAncestor(Operator.class.getName(), parent)) { throw new IllegalArgumentException("Argument must be a subclass of Operator class"); } } Set<String> filteredClass = Sets.filter( operatorClassNames, new Predicate<String>() { @Override public boolean apply(String className) { OperatorClassInfo oci = classInfo.get(className); return oci == null || !oci.tags.containsKey("@omitFromUI"); } }); if (searchTerm == null && parent.equals(Operator.class.getName())) { return filteredClass; } if (searchTerm != null) { searchTerm = searchTerm.toLowerCase(); } Set<String> result = new HashSet<String>(); for (String clazz : filteredClass) { if (parent.equals(Operator.class.getName()) || typeGraph.isAncestor(parent, clazz)) { if (searchTerm == null) { result.add(clazz); } else { if (clazz.toLowerCase().contains(searchTerm)) { result.add(clazz); } else { OperatorClassInfo oci = classInfo.get(clazz); if (oci != null) { if (oci.comment != null && oci.comment.toLowerCase().contains(searchTerm)) { result.add(clazz); } else { for (Map.Entry<String, String> entry : oci.tags.entrySet()) { if (entry.getValue().toLowerCase().contains(searchTerm)) { result.add(clazz); break; } } } } } } } } return result; }
/** * Adds the channel-bundles of this <tt>Conference</tt> as * <tt>ColibriConferenceIQ.ChannelBundle</tt> instances in <tt>iq</tt>. * * @param iq the <tt>ColibriConferenceIQ</tt> in which to describe. */ void describeChannelBundles(ColibriConferenceIQ iq) { synchronized (transportManagers) { for (Map.Entry<String, IceUdpTransportManager> entry : transportManagers.entrySet()) { ColibriConferenceIQ.ChannelBundle responseBundleIQ = new ColibriConferenceIQ.ChannelBundle(entry.getKey()); entry.getValue().describe(responseBundleIQ); iq.addChannelBundle(responseBundleIQ); } } }
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; }
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); } }