/** @param args */ public static void main(String[] args) { Set<DomainObject> objectSet = new TreeSet<DomainObject>(new DomainObjectComparator()); objectSet.add(DomainFactory.createDomainObject("Helga", "Mutter")); objectSet.add(DomainFactory.createDomainObject("Walter", "Vater")); objectSet.add(DomainFactory.createDomainObject("Hannah", "Tochter1")); objectSet.add(DomainFactory.createDomainObject("Paul", "Sohn")); objectSet.add(DomainFactory.createDomainObject("Claudia", "Tochter2")); for (DomainObject domainObject : objectSet) { LOGGER.debug(domainObject.getUuid()); LOGGER.debug(domainObject.toString()); } }
private OOFactSet create_factset(Class<?> classObj, boolean all_discrete) { // System.out.println("WorkingMemory.create_factset element "+ element ); OOFactSet newfs = new OOFactSet(classObj); Field[] element_fields = classObj.getDeclaredFields(); for (Field f : element_fields) { String f_name = f.getName(); Class<?>[] f_class = {f.getType()}; System.out.println( "WHat is this f: " + f.getType() + " the name " + f_name + " class " + f.getClass() + " and the name" + f.getClass().getName()); if (Util.isSimpleType(f_class)) { Domain<?> fieldDomain; if (!domainset.containsKey(f_name)) { fieldDomain = DomainFactory.createDomainFromClass(f.getType(), f_name); domainset.put(f_name, fieldDomain); } else fieldDomain = domainset.get(f_name); Annotation[] annotations = f.getAnnotations(); // iterate over the annotations to locate the MaxLength constraint if it exists DomainSpec spec = null; for (Annotation a : annotations) { if (a instanceof DomainSpec) { spec = (DomainSpec) a; // here it is !!! break; } } if (spec != null) { fieldDomain.setReadingSeq(spec.readingSeq()); if (!all_discrete) fieldDomain.setDiscrete(spec.discrete()); } /* * ID3 would * if it is integer and the annotation saying that the field is continuous * ignore the domain * if it is double / float and the annotation saying that the field is continuous * ignore the domain if it has more than 10 values ? * if it is string and the annotation saying that the field is continuous * what to do?? */ newfs.addDomain(f_name, fieldDomain); } } factsets.put(classObj.getName(), newfs); return newfs; }
private DomainResource getDomainResource(String domainString) { try { logger.info("Fetching domain: " + domainString); Domain domain = factory.getDomain(domainString); Name domainName = Utils.stringToName(domainString); DomainResource dr = DomainResource.fromDomain(domain, domainName); return dr; } catch (ForeignDomainException e) { logger.error("Iterator returned foreign domain: " + domainString); throw new RuntimeException(e); } catch (TextParseException e) { logger.error("Invalid domain name: " + e.getMessage()); throw new RuntimeException(e); } }
private OOFactSet create_factset_(Class<?> classObj) { // System.out.println("WorkingMemory.create_factset element "+ element ); OOFactSet newfs = new OOFactSet(classObj); Method[] element_methods = classObj.getDeclaredMethods(); for (Method m : element_methods) { String m_name = m.getName(); Class<?>[] returns = {m.getReturnType()}; // System.out.println("WorkingMemory.create_factset m "+ m + " method name "+m_name+" // return_type_name: "+return_type_name+"."); if (Util.isGetter(m_name) & Util.isSimpleType(returns)) { String field = Util.getAttributeName(m_name); /* * when u first read the element * if the domain specifications are already given * then read from there and * dont add each new value you read, just check if it is valid * otherwise you create a new domain for that attribute * Domain attributeSpec = dataSetSpec.getDomain(attr_name); */ Domain<?> fieldDomain; if (!domainset.containsKey(field)) fieldDomain = DomainFactory.createDomainFromClass(m.getReturnType(), field); else fieldDomain = domainset.get(field); // System.out.println("WorkingMemory.create_factset field "+ field + " fielddomain name // "+fieldDomain.getName()+" return_type_name: "+return_type_name+"."); domainset.put(field, fieldDomain); newfs.addDomain(field, fieldDomain); // System.out.println("START: WorkingMemory.create_factset domainset size "+ // domainset.size() + " newfs size "+newfs.getFacts().size()+"."); } } factsets.put(classObj.getName(), newfs); return newfs; }