@Override protected OProperty loadInstance() { OClass oClass = classModel!=null?classModel.getObject():null; return oClass!=null && propertyName!=null?oClass.getProperty(propertyName):null; }
protected OCollate getCollateForField(final OClass iClass, final String iFieldName) { if (iClass != null) { final OProperty p = iClass.getProperty(iFieldName); if (p != null) return p.getCollate(); } return null; }
private static String adjustFieldName(final OClass clazz, final String fieldName) { final OProperty property = clazz.getProperty(fieldName); if (property != null) return property.getName(); else return fieldName; } }
public OCollate getCollate(OResult currentRecord, OCommandContext ctx) { if (identifier != null && currentRecord != null) { return currentRecord.getRecord().map(x -> (OElement) x).flatMap(elem -> elem.getSchemaType()) .map(clazz -> clazz.getProperty(identifier.getStringValue())).map(prop -> prop.getCollate()).orElse(null); } return null; }
private OType determineType(ODocument doc, String fieldName) { OType type = null; final OClass cls = ODocumentInternal.getImmutableSchemaClass(doc); if (cls != null) { final OProperty prop = cls.getProperty(fieldName); if (prop != null) type = prop.getType(); } return type; }
private OType getLinkedType(ODocument document, OType type, String key) { if (type != OType.EMBEDDEDLIST && type != OType.EMBEDDEDSET && type != OType.EMBEDDEDMAP) return null; OClass immutableClass = ODocumentInternal.getImmutableSchemaClass(document); if (immutableClass != null) { OProperty prop = immutableClass.getProperty(key); if (prop != null) { return prop.getLinkedType(); } } return null; }
private OType getLinkedType(ODocument document, OType type, String key) { if (type != OType.EMBEDDEDLIST && type != OType.EMBEDDEDSET && type != OType.EMBEDDEDMAP) return null; OClass immutableClass = ODocumentInternal.getImmutableSchemaClass(document); if (immutableClass != null) { OProperty prop = immutableClass.getProperty(key); if (prop != null) { return prop.getLinkedType(); } } return null; }
protected OType getLinkedType(ODocument document, OType type, String key) { if (type != OType.EMBEDDEDLIST && type != OType.EMBEDDEDSET && type != OType.EMBEDDEDMAP) return null; OClass immutableClass = ODocumentInternal.getImmutableSchemaClass(document); if (immutableClass != null) { OProperty prop = immutableClass.getProperty(key); if (prop != null) { return prop.getLinkedType(); } } return null; }
private void updateFieldToStore(OIndexDefinition indexDefinition) { List<String> fields = indexDefinition.getFields(); for (String field : fields) { OProperty property = indexClass.getProperty(field); if (property.getType().isEmbedded() && property.getLinkedType() != null) { fieldsToStore.put(field, true); } else { fieldsToStore.put(field, false); } } }
protected OProperty getProperty(final int column) throws SQLException { String fieldName = getColumnName(column); return getCurrentRecord().toElement().getSchemaType() .map(st -> st.getProperty(fieldName)) .orElse(null); }
public boolean isIndexChain(OCommandContext ctx, OClass clazz) { if (suffix != null && suffix.isBaseIdentifier()) { OProperty prop = clazz.getProperty(suffix.identifier.getStringValue()); if (prop == null) { return false; } Collection<OIndex<?>> allIndexes = prop.getAllIndexes(); return allIndexes != null && allIndexes.stream().anyMatch(idx -> idx.getDefinition().getFields().size() == 1); } return false; } }
private void modifyCaseInsensitiveNameField(final OClass type) { log.info("Modifying case-insensitive name field on component"); OProperty ciNameProperty = type.getProperty(P_CI_NAME); if (!ciNameProperty.isMandatory()) { ciNameProperty.setMandatory(true); } if (!ciNameProperty.isNotNull()) { ciNameProperty.setNotNull(true); } }
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; }
private boolean checkIndexChainExistence(OClass iSchemaClass, OIndexSearchResult result) { final int fieldCount = result.lastField.getItemCount(); OClass cls = iSchemaClass.getProperty(result.lastField.getItemName(0)).getLinkedClass(); for (int i = 1; i < fieldCount; i++) { if (cls == null || !cls.areIndexed(result.lastField.getItemName(i))) { return false; } cls = cls.getProperty(result.lastField.getItemName(i)).getLinkedClass(); } return true; } }
private void checkCollectionIndex(OIndexDefinition indexDefinition) { List<String> fields = indexDefinition.getFields(); OClass aClass = getDatabase().getMetadata().getSchema().getClass(indexDefinition.getClassName()); for (String field : fields) { OProperty property = aClass.getProperty(field); if (property.getType().isEmbedded() && property.getLinkedType() != null) { collectionFields.put(field, true); } else { collectionFields.put(field, false); } } }
@Override public void loadSettings() { super.loadSettings(); ODocument doc = getWidgetDocument(); if(doc!=null) { String propertyName = doc.field("property"); OProperty property = getModelObject().getSchemaClass().getProperty(propertyName); propertyModel.setObject(property); } }
private OScheduledEvent createRestorePasswordSchedulerEvent(ODatabaseDocument db, OrienteerUser user, String eventName) { OProperty property = user.getDocument().getSchemaClass().getProperty(OrienteerUser.PROP_RESTORE_ID); OFunction fun = db.getMetadata().getFunctionLibrary().getFunction(OrienteerUsersModule.FUN_REMOVE_RESTORE_ID); long timeout = Long.parseLong(OrienteerUsersModule.REMOVE_SCHEDULE_START_TIMEOUT.getValue(property)); return new OScheduledEventBuilder() .setName(eventName) .setFunction(fun) .setArguments(createFunArguments(user, timeout, eventName)) .setRule(OrienteerUsersModule.REMOVE_CRON_RULE.getValue(property)) .setStartTime(new Date(System.currentTimeMillis() + timeout)).build(); }
@Override public void setValue(Object object, Object value, PropertyResolverConverter converter) { ODocument doc = toODocument(object); if(value!=null && ! OType.isSimpleType(value)) { //Try to convert if type is not simple OClass schemaClass = doc.getSchemaClass(); OProperty property = schemaClass.getProperty(exp); if(property!=null) { value = converter.convert(value, property.getType().getDefaultJavaType()); } } doc.field(exp, value); }
@Override protected OProperty doBackward(String b) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); OSchema schema = db.getMetadata().getSchema(); String className = Strings.beforeFirst(b, '.'); String propertyName = Strings.afterFirst(b, '.'); OClass oClass = schema.getClass(className); return oClass.getProperty(propertyName); }
@Override protected OProperty doBackward(String b) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); OSchema schema = db.getMetadata().getSchema(); String className = Strings.beforeFirst(b, '.'); String propertyName = Strings.afterFirst(b, '.'); OClass oClass = schema.getClass(className); return oClass.getProperty(propertyName); }