Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OClass#getSuperClasses()

The following examples show how to use com.orientechnologies.orient.core.metadata.schema.OClass#getSuperClasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomAttribute.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public <V> V getValue(OClass oClass, V defaultValue, boolean hiearchical)
{
	String stringValue = oClass.getCustom(name);
	if(encode) stringValue = decodeCustomValue(stringValue);
	V ret;
	if(OProperty.class.isAssignableFrom(javaClass))
	{
		ret = (V)resolveProperty(oClass, stringValue);
	}
	else
	{
		ret = (V) OType.convert(stringValue, javaClass);
	}
	if(ret==null && hiearchical) {
		for(OClass superClass : oClass.getSuperClasses()) {
			if((ret=getValue(superClass, null, true))!=null) break;
		}
	}
	return ret!=null?ret:defaultValue;
}
 
Example 2
Source File: PlantUmlService.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public void describe(Writer writer, OClass oClass)
{
	PrintWriter out = toPrintWriter(writer);
	out.append(oClass.isAbstract()?"abstract":"class").append(" ").append(oClass.getName());
	List<OClass> superClasses = oClass.getSuperClasses();
	if(superClasses!=null && !superClasses.isEmpty()) {
		for(int i=0; i<superClasses.size();i++){
			out.append(i==0?" extends ":", ");
			out.append(superClasses.get(i).getName());
		}
	}
	out.println();
	for(OProperty property: oClass.declaredProperties())
	{
		describe(out, property);
	}
	out.println();
}
 
Example 3
Source File: OArchitectClassesUtils.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private static boolean isSubClassProperty(OProperty property, List<OClass> superClasses) {
    boolean isSubClass = false;
    for (OClass oClass : superClasses) {
        isSubClass = oClass.getProperty(property.getName()) != null;
        if (!isSubClass) {
            List<OClass> classes = oClass.getSuperClasses();
            if (classes != null && !classes.isEmpty()) {
                isSubClass = isSubClassProperty(property, classes);
            }
        } else break;
    }
    return isSubClass;
}
 
Example 4
Source File: OClassMetaPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected V getValue(OClass entity, String critery) {
	CustomAttribute custom;
	if("clusterSelection".equals(critery))
	{
		OClusterSelectionStrategy strategy = entity.getClusterSelection();
		return (V)(strategy!=null?strategy.getName():null);
	}
	else if(OClassPrototyper.SUPER_CLASSES.equals(critery))
	{
		List<OClass> superClasses = entity.getSuperClasses();
		// Additional wrapping to ArrayList is required , because getSuperClasses return unmodifiable list
		return (V)(superClasses != null ? new ArrayList<OClass>(superClasses) : new ArrayList<OClass>());
	}
	else if((CustomAttribute.ON_CREATE_FIELDS.getName().equals(critery)) && (custom = CustomAttribute.getIfExists(critery)) != null)
	{
		String onCreateFields = custom.getValue(entity);
		return (V)(!Strings.isNullOrEmpty(onCreateFields)
				? Lists.newArrayList(onCreateFields.split(","))
				: new ArrayList<String>());
	}
	else if((custom = CustomAttribute.getIfExists(critery))!=null)
	{
		return custom.getValue(entity);
	}
	else
	{
		return (V)PropertyResolver.getValue(critery, entity);
	}
}
 
Example 5
Source File: SchemaPageHeader.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected List<OClass> load() {
	OClass currentClass = SchemaPageHeader.this.getModelObject();
	List<OClass> superClasses;
	List<OClass> breadCrumbs = new ArrayList<OClass>();
	if (currentClass != null) {
		while ((superClasses = currentClass.getSuperClasses()) != null && !superClasses.isEmpty()) {
			currentClass = superClasses.get(0);
			breadCrumbs.add(currentClass);
		}
		breadCrumbs = Lists.reverse(breadCrumbs);
	}
	return breadCrumbs;
}