Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OProperty#setLinkedClass()
The following examples show how to use
com.orientechnologies.orient.core.metadata.schema.OProperty#setLinkedClass() .
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: ApplyEditorChangesBehavior.java From Orienteer with Apache License 2.0 | 5 votes |
private void setLinkedClassForProperty(OArchitectOProperty architectProperty, OProperty property, OSchema schema) { OClass linkedClass = schema.getOrCreateClass(architectProperty.getLinkedClass()); property.setLinkedClass(linkedClass); if (architectProperty.getInverseProperty() != null) { OArchitectOProperty p = architectProperty.getInverseProperty(); if (!Strings.isNullOrEmpty(p.getName()) && p.getType() != null) { OProperty inverseProp = linkedClass.getProperty(p.getName()); if (inverseProp == null) { inverseProp = linkedClass.createProperty(p.getName(), p.getType()); } CustomAttribute.PROP_INVERSE.setValue(property, inverseProp); } } }
Example 2
Source File: OSchemaHelper.java From Orienteer with Apache License 2.0 | 5 votes |
public OSchemaHelper setupRelationship(String class1Name, String property1Name, String class2Name, String property2Name) { OClass class1 = schema.getClass(class1Name); OProperty property1 = class1.getProperty(property1Name); OClass class2 = schema.getClass(class2Name); OProperty property2 = class2.getProperty(property2Name); if(!Objects.equals(property1.getLinkedClass(), class2)) property1.setLinkedClass(class2); if(!Objects.equals(property2.getLinkedClass(), class1)) property2.setLinkedClass(class1); CustomAttribute.PROP_INVERSE.setValue(property1, property2); CustomAttribute.PROP_INVERSE.setValue(property2, property1); return this; }
Example 3
Source File: OSchemaHelper.java From Orienteer with Apache License 2.0 | 5 votes |
public OSchemaHelper setupRelationship(String class1Name, String propertyName, String class2Name) { OClass class1 = schema.getClass(class1Name); OProperty property = class1.getProperty(propertyName); OClass class2 = schema.getClass(class2Name); if (!Objects.equals(property.getLinkedClass(), class2)) property.setLinkedClass(class2); return this; }
Example 4
Source File: OClassIntrospector.java From Orienteer with Apache License 2.0 | 4 votes |
@Override public OProperty virtualizeField(ODocument doc, String field) { OProperty property = OPropertyPrototyper.newPrototype(doc.getClassName()); property.setName(field); OType oType = doc.fieldType(field); if(oType==null) oType=OType.ANY; property.setType(oType); switch (oType) { case LINK: OIdentifiable link = doc.field(field); if(link!=null && link instanceof ODocument) property.setLinkedClass(((ODocument)link).getSchemaClass()); break; case LINKBAG: OCollection<OIdentifiable> bag = doc.field(field); if(bag!=null && bag.size()>0) { OIdentifiable linkIdentifiable = bag.iterator().next(); ORecord record = linkIdentifiable!=null?linkIdentifiable.getRecord():null; if(record!=null && record instanceof ODocument) property.setLinkedClass(((ODocument)record).getSchemaClass()); } break; case LINKLIST: case LINKSET: Collection<ODocument> collection = doc.field(field); if(collection!=null && !collection.isEmpty()) { link = collection.iterator().next(); if(link!=null && link instanceof ODocument) property.setLinkedClass(((ODocument)link).getSchemaClass()); } break; case LINKMAP: Map<String, ODocument> map = doc.field(field); if(map!=null && !map.isEmpty()) { link = map.values().iterator().next(); if(link!=null && link instanceof ODocument) property.setLinkedClass(((ODocument)link).getSchemaClass()); } break; case EMBEDDED: Object value = doc.field(field); OType linkedType = OType.getTypeByValue(value); if(OType.EMBEDDED.equals(linkedType)) property.setLinkedClass(((ODocument)value).getSchemaClass()); else property.setLinkedType(linkedType); break; case EMBEDDEDSET: case EMBEDDEDLIST: Collection<Object> objectCollection = doc.field(field); if(objectCollection!=null && !objectCollection.isEmpty()) { value = objectCollection.iterator().next(); property.setLinkedType(OType.getTypeByValue(value)); } break; case EMBEDDEDMAP: Map<String, Object> objectMap = doc.field(field); if(objectMap!=null && !objectMap.isEmpty()) { value = objectMap.values().iterator().next(); property.setLinkedType(OType.getTypeByValue(value)); } break; default: break; } return property; }