Hello CS Community!
Some questions…
1, We are trying to replicate some of the administration in the “Centra Site Control” program via the jaxr programming interface. To understand how to do this we have been searching for code-examples showing creation of types (Asset Types is the term in the gui, Concept, I think, in the jaxr world) (both relationship types and others, complete with the creation of ‘fields’ and relationships).
Does anybody have a working code-example of how to do this?
2, Are there a “world map” of the register? An explanation of where categories of resources are placed, like where to get user defined types?
3, We are trying to make a generic search method for searching for user defined objects. One attempt looks like this:
public <T> List<T> find(T match) {
try {
Collection<String> instructions = new ArrayList<String>();
instructions.add(FindQualifier.COMBINE_CLASSIFICATIONS);
BeanMap bm = new BeanMap(match);
StringBuilder sb = new StringBuilder();
for (String key: bm.keySet()) {
Object value = bm.get(key);
//if (value != null && !"".equals(value) && value) {
if (value instanceof String) {
//sb.append("text($ro/@" + key + ") = text(" + value + ") and");
//sb.append("$ro/" + key + "] != \"" + value + "\" and");
//sb.append("$ro/" + key + " != \"" + value + "\" and");
//sb.append("$ro/" + nameSpace + ":" + key + " != \"" + value + "\" and");
//sb.append("compare($ro/@" +key + ", \""+value+"\") = 0");
//sb.append("compare('a', 'a') = 0");
//sb.append("bla " + key + " = " + value + " and");
//sb.append("compare($ro/@" + key + ", \"xyz\") = 0");
sb.append("$ro/" + key + " = \"" + value + "\" and");
}
}
if (sb.toString().endsWith(" and")) {
sb.delete(sb.length()-3, sb.length());
}
String query = sb.toString();
if (query.length() == 0) {
query = null;
}
System.out.println(sb);
String typeName = "{" + nameSpace + "}" + match.getClass().getSimpleName();
//String typeName = "{" + nameSpace + "}*"; // + match.getClass().getSimpleName();
//BulkResponse result = queryManager.findObjects(instructions, typeName, null, sb.toString());
BulkResponse result = queryManager.findObjects(instructions, typeName, null, query);
List<T> beans = new ArrayList<T>();
for (Object o: result.getCollection()) {
RegistryEntry re = (RegistryEntry) o;
T newItem = (T) match.getClass().newInstance();
BeanMap newItemMap = new BeanMap(newItem);
for (String key: newItemMap.keySet()) {
Slot slot = re.getSlot("{" + nameSpace + "}" + key);
if (slot != null && !slot.getValues().isEmpty()) {
newItemMap.put(key, slot.getValues().iterator().next());
}
}
beans.add(newItem);
}
return beans;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
… this works… kind of, when no condition is provided in the for loop appending something like sb.append(“$ro/” + key + " = "" + value + “" and”); (is never run, the code is never appended) then all the kinds of the object type is returned. When we try to have any kind of comparison whit the value in the post it returns nothing. Does anybody know how to write a XQuery condition like dbfield = someValue?
Kind regards
ClaesL