* create a template item from a given class
* @param c
* @return
*/
private static TemplateItem convertSlideTutorClass(IClass c, Template template) {
IOntology ont = c.getOntology();
TemplateItem item = new TemplateItem();
item.setTemplate(template);
item.setConcept(c.getConcept());
item.getConcept().setCode(getCode(item.getConcept().getCode(),true));
item.setValueDomain(TemplateItem.DOMAIN_BOOLEAN);
// figure out type
if(isFeature(c)){
item.setType(TemplateItem.TYPE_FINDING);
}else if(isAttributeCategory(c)){
item.setType(TemplateItem.TYPE_ATTRIBUTE);
}else if(isLocation(c)){
item.setType(TemplateItem.TYPE_ATTRIBUTE_VALUE);
}else if(isNumber(c)){
item.setType(TemplateItem.TYPE_NUMERIC_VALUE);
}else if(isModifier(c)){
item.setType(TemplateItem.TYPE_MODIFIER);
}else if(isDisease(c)){
item.setType(TemplateItem.TYPE_DIAGNOSIS);
item.setValueDomain(TemplateItem.DOMAIN_SELF);
}
// if feature process attributes
if(isFeature(c)){
IClass feature = getFeature(c);
if(!feature.equals(c)){
item.setFeature(convertSlideTutorClass(feature,template));
// if feature is a child of value then, it is a fully specified feature attr/value, and
// we just need a feature
if(isOfParent(c,VALUES))
item = item.getFeature();
// if we have a more general feature specified, then
}
// process potential attributes
for(IClass attribute: getPotentialTemplateAttributes(c)){
// if used attribute, skip
//if(!usedAttributes.contains(attribute))
// continue;
TemplateItem a = convertSlideTutorClass(attribute,template);
// handle numbers
if(isNumber(attribute)){
item.getValues().add(a);
item.setValueDomain(TemplateItem.DOMAIN_VALUE);
// handle units
}else if(isOfParent(attribute,"UNITS")){
item.getUnits().add(a);
// handle locations
}else if(isLocation(attribute)){
TemplateItem l = convertSlideTutorClass(ont.getClass(LOCATIONS), template);
item.addAttributeValue(l,a);
// handle attributes with categories and modifiers
}else if(isModifier(attribute)){
if(!attribute.hasSubClass(c))
item.setValueDomain(TemplateItem.DOMAIN_ATTRIBUTE);
for(IClass acat : attribute.getDirectSuperClasses()){
if(isAttributeCategory(acat) && !acat.equals(ont.getClass(MODIFIERS))){
TemplateItem l = convertSlideTutorClass(acat, template);
item.addAttributeValue(l, a);
}else{
item.addModifier(a);
}
}
}else{
//System.err.println(attribute);
}
}
// do something special for worksheet?
if(isWorksheet(c)){
item.setValueDomain(TemplateItem.DOMAIN_SELF);
}else if(isHeader(c)){
item.setValueDomain(TemplateItem.DOMAIN_SELF);
}
// anatomic location?
if(isAnatomicLocation(c)){
item.setType(TemplateItem.TYPE_ORGAN);
String code = getCode((String) c.getPropertyValue(ont.getProperty("code")),true);
if(code != null){
String cd = (code.indexOf("#") > -1)?code.substring(0,code.lastIndexOf("#")):code;
String nm = (cd.indexOf("/") > -1)?cd.substring(cd.lastIndexOf("/")+1):cd;
Source src = new Source(nm, "", cd);
try {