use of com.eden.common.json.JSONElement in project Orchid by JavaEden.
the class OrchidUtils method findInMap.
private static String findInMap(String link, JSONObject mapObject, String displayName) {
List urls = WalkMapFilter.walkObject(mapObject, "url");
String template = "<a href=\"#{$1}\">#{$2}</a>";
for (Object object : urls) {
if (object instanceof Map) {
Map map = (Map) object;
if (map.containsKey("url")) {
JSONElement element = new JSONElement(new JSONObject(map));
if (OrchidUtils.elementIsString(element.query("data.info.qualifiedName")) && element.query("data.info.qualifiedName").toString().equals(link)) {
if (!EdenUtils.isEmpty(displayName)) {
return Clog.format(template, map.get("url"), displayName);
} else {
return Clog.format(template, map.get("url"), map.get("name"));
}
} else if (map.containsKey("name") && map.get("name").toString().equals(link)) {
if (!EdenUtils.isEmpty(displayName)) {
return Clog.format(template, map.get("url"), displayName);
} else {
return Clog.format(template, map.get("url"), map.get("name"));
}
}
}
}
}
return null;
}
use of com.eden.common.json.JSONElement in project Orchid by JavaEden.
the class PrioritizedSetFilter method getFilteredSet.
public Set<T> getFilteredSet() {
if (fullFilteredSet != null) {
return fullFilteredSet;
}
JSONElement element = context.query("options." + key);
Stream<T> filter = originalSet.stream();
if (OrchidUtils.elementIsObject(element)) {
JSONObject filterQuery = (JSONObject) element.getElement();
if (filterQuery.has(ALLOWED_KEY) && filterQuery.get(ALLOWED_KEY) instanceof JSONArray) {
JSONArray allowedItems = filterQuery.getJSONArray(ALLOWED_KEY);
if (allowedItems.length() > 0) {
Clog.v("PrioritizedSetFilter '#{$1}' applying filters to whitelist items", new Object[] { key });
filter = filter.filter(t -> {
boolean inAllowedItems = false;
for (int i = 0; i < allowedItems.length(); i++) {
inAllowedItems = t.getClass().getSimpleName().equals(allowedItems.getString(i));
inAllowedItems = inAllowedItems || (t.getClass().getName().equals(allowedItems.getString(i)));
if (inAllowedItems) {
break;
}
}
return inAllowedItems;
});
}
}
if (filterQuery.has(DISABLED_KEY) && filterQuery.get(DISABLED_KEY) instanceof JSONArray) {
JSONArray disabledItems = filterQuery.getJSONArray(DISABLED_KEY);
if (disabledItems.length() > 0) {
Clog.v("PrioritizedSetFilter '#{$1}' applying filters to blacklist items", new Object[] { key });
filter = filter.filter(t -> {
boolean inDisallowedItems = false;
for (int i = 0; i < disabledItems.length(); i++) {
inDisallowedItems = t.getClass().getSimpleName().equals(disabledItems.getString(i));
inDisallowedItems = inDisallowedItems || (t.getClass().getName().equals(disabledItems.getString(i)));
if (inDisallowedItems) {
break;
}
}
return !inDisallowedItems;
});
}
}
}
Set<T> initialFilteredSet = filter.collect(Collectors.toSet());
initialFilteredSet = (Set<T>) context.getFilterService().filter("filter:" + key, initialFilteredSet);
fullFilteredSet = new ObservableTreeSet<>(initialFilteredSet);
return fullFilteredSet;
}
use of com.eden.common.json.JSONElement in project Orchid by JavaEden.
the class ClassDocParser method getDirectSubclasses.
public JSONArray getDirectSubclasses(ClassDoc classDoc) {
Map<String, JSONObject> relatedClasses = new HashMap<>();
JSONArray fields = new JSONArray();
JSONArray element = OrchidUtils.queryIndex(context, "javadoc");
for (int i = 0; i < element.length(); i++) {
JSONObject object = element.getJSONObject(i);
JSONElement objectElement = new JSONElement(object);
if (objectElement.query("data.info") != null && objectElement.query("data.info.superclass") != null) {
String objectQualifiedName = objectElement.query("data.info.qualifiedName").getElement().toString();
String superclassQualifiedName = objectElement.query("data.info.superclass.qualifiedName").getElement().toString();
if (superclassQualifiedName.equals(classDoc.qualifiedName()) && !relatedClasses.containsKey(objectQualifiedName)) {
relatedClasses.put(objectQualifiedName, object);
fields.put(object);
}
}
}
return fields;
}
Aggregations