@Override protected String doForward(OProperty a) { return a.getFullName(); }
@Override public String getFullName() { return delegate.getFullName(); }
@Override public String getResourceKey(OProperty object) { return object.getFullName(); }
@Override protected String doForward(OProperty a) { return a.getFullName(); }
@Override public String getResourceKey(OProperty object) { return object.getFullName(); }
/** * Create {@link OIndex} if required on a current property * @param type type of an {@link OIndex} * @return this helper */ public OSchemaHelper oIndex(INDEX_TYPE type) { checkOProperty(); return oIndex(lastProperty.getFullName(), type); }
/** * Create {@link OIndex} if required on a current property * @param type type of an {@link OIndex} * @return this helper */ public OSchemaHelper oIndex(INDEX_TYPE type) { checkOProperty(); return oIndex(lastProperty.getFullName(), type); }
public <V> void setValue(OProperty property, V value) { if(OProperty.class.isAssignableFrom(javaClass) && value instanceof OProperty) { OProperty valueProperty = (OProperty)value; boolean fullNameRequired = !Objects.equals(property.getOwnerClass(), valueProperty.getOwnerClass()); property.setCustom(name, fullNameRequired?valueProperty.getFullName():valueProperty.getName()); } else { if(defaultValue!=null && defaultValue.equals(value)) value = null; String stringValue = value!=null?value.toString():null; if(stringValue!=null && stringValue.length()==0) stringValue=null; if(encode) stringValue = encodeCustomValue(stringValue); property.setCustom(name, stringValue); } }
public <V> void setValue(OClass oClass, V value, boolean hiearchical) { if(hiearchical && Objects.equals(value, getValue(oClass, true))) return; if(OProperty.class.isAssignableFrom(javaClass) && value instanceof OProperty) { OProperty valueProperty = (OProperty)value; boolean fullNameRequired = !Objects.equals(oClass, valueProperty.getOwnerClass()); oClass.setCustom(name, fullNameRequired?valueProperty.getFullName():valueProperty.getName()); } else { if(!hiearchical && defaultValue!=null && defaultValue.equals(value)) value = null; String stringValue = value!=null?value.toString():null; if(stringValue!=null && stringValue.length()==0) stringValue=null; if(encode) stringValue = encodeCustomValue(stringValue); oClass.setCustom(name, stringValue); } }
protected ValidationError newValidationError(String variation, Object... params) { ValidationError error = new ValidationError(this, variation); error.setVariable("property", getProperty().getFullName()); error.setVariable("type", getProperty().getType()); for (int i = 0; i < params.length; i += 2) { error.setVariable(params[i].toString(), params[i + 1]); } return error; }
protected ValidationError newValidationError(String variation, Object... params) { ValidationError error = new ValidationError(this, variation); error.setVariable("property", getProperty().getFullName()); error.setVariable("type", getProperty().getType()); for (int i = 0; i < params.length; i += 2) { error.setVariable(params[i].toString(), params[i + 1]); } return error; }
protected static void validateType(final OProperty p, final Object value) { if (value != null) if (OType.convert(value, p.getLinkedType().getDefaultJavaType()) == null) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " of type '" + p.getLinkedType() + "' but the value is " + value); }
if (fieldValue instanceof ORecordId) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " but the value is the RecordID " + fieldValue); else if (fieldValue instanceof OIdentifiable) { final OIdentifiable embedded = (OIdentifiable) fieldValue; if (embedded.getIdentity().isValid()) throw new OValidationException("The field '" + p.getFullName() + "' has been declared as " + p.getType() + " but the value is a document with the valid RecordID " + fieldValue); if (!(embeddedRecord instanceof ODocument)) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " with linked class '" + embeddedClass + "' but the record was not a document"); if (doc.getImmutableSchemaClass() == null) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " with linked class '" + embeddedClass + "' but the record has no class"); "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " with linked class '" + embeddedClass + "' but the record is of class '" + doc.getImmutableSchemaClass().getName() + "' that is not a subclass of that"); "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " but an incompatible type is used. Value: " + fieldValue);
return; else throw new OValidationException("The field '" + p.getFullName() + "' has been declared as " + p.getType() + " but contains a null record (probably a deleted record?)"); throw new OValidationException("The field '" + p.getFullName() + "' has been declared as " + p.getType() + " but the value is not a record or a record-id"); final OClass schemaClass = p.getLinkedClass(); if (!(linkedRecord instanceof ODocument)) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " of type '" + schemaClass + "' but the value is the record " + linkedRecord.getIdentity() + " that is not a document"); "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " of type '" + schemaClass.getName() + "' but the value is the document " + linkedRecord.getIdentity() + " of class '" + doc .getImmutableSchemaClass() + "'");
@SuppressWarnings("unchecked") @Override public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { if (DisplayMode.EDIT.equals(mode)) { OProperty property = propertyModel.getObject(); OClass oClass = property.getLinkedClass(); if(oClass!=null) { AbstractSelect2Choice<?, ?> choice = property.getType().isMultiValue() ? new Select2MultiChoice<ODocument>(id, (IModel<Collection<ODocument>>) valueModel, new ODocumentChoiceProvider(oClass)) : new Select2Choice<ODocument>(id, (IModel<ODocument>) valueModel, new ODocumentChoiceProvider(oClass)); choice.getSettings() .setWidth("100%") .setCloseOnSelect(true) .setTheme(OClassMetaPanel.BOOTSTRAP_SELECT2_THEME); return choice; } else { LOG.warn("Property '"+property.getFullName()+"' doesn't have linked class specified."); } } return null; }
message("\nPROPERTY '" + prop.getFullName() + "'\n"); message("\nType.................: " + prop.getType()); message("\nMandatory............: " + prop.isMandatory());
@Override public ODocument onInstall(OrienteerWebApplication app, ODatabaseDocument db) { OSchemaHelper helper = OSchemaHelper.bind(db); OClass user = helper.oClass(OUser.CLASS_NAME) .oProperty(OrienteerUser.PROP_ID, OType.STRING).notNull() .updateCustomAttribute(CustomAttribute.UI_READONLY, true) .oProperty(OrienteerUser.PROP_RESTORE_ID, OType.STRING) .updateCustomAttribute(CustomAttribute.UI_READONLY, true) .updateCustomAttribute(REMOVE_CRON_RULE, "0 0/1 * * * ?") .updateCustomAttribute(REMOVE_SCHEDULE_START_TIMEOUT, "86400000") .oProperty(OrienteerUser.PROP_RESTORE_ID_CREATED, OType.DATETIME) .updateCustomAttribute(CustomAttribute.UI_READONLY, true) .oProperty(OrienteerUser.PROP_EMAIL, OType.STRING).notNull() .oProperty(OrienteerUser.PROP_FIRST_NAME, OType.STRING) .oProperty(OrienteerUser.PROP_LAST_NAME, OType.STRING) .getOClass(); updateDefaultOrienteerUsers(db); helper.oIndex(user.getProperty(OrienteerUser.PROP_ID).getFullName(), OClass.INDEX_TYPE.UNIQUE, OrienteerUser.PROP_ID); helper.oIndex(user.getProperty(OrienteerUser.PROP_EMAIL).getFullName(), OClass.INDEX_TYPE.UNIQUE, OrienteerUser.PROP_EMAIL); OUsersCommonUtils.setRestricted(db, helper.oClass(OIdentity.CLASS_NAME).getOClass()); OUsersCommonUtils.setRestricted(db, helper.oClass(PerspectivesModule.OCLASS_PERSPECTIVE).getOClass()); ODocument perspective = createOrienteerUsersPerspective(db); ODocument readerPerspective = createReaderPespective(db); ODocument reader = updateAndGetUserReader(db); updateReaderPermissions(db, reader, readerPerspective); updateOrienteerUserRoleDoc(db, perspective); createRemoveRestoreIdFunction(helper); return null; }
LOG.info("Rendering page for property '"+oProperty.getFullName()+"'"); tester.startPage(OPropertyPage.class, parameters); tester.assertRenderedPage(OPropertyPage.class);
public OImmutableProperty(OProperty property, OImmutableClass owner) { name = property.getName(); fullName = property.getFullName(); type = property.getType(); description = property.getDescription();
assertEquals("newProperty", newProperty.getName()); assertNull(newClass.getProperty("newProperty")); assertEquals("NewClass.newProperty", newProperty.getFullName()); newProperty.setType(OType.STRING); assertEquals(OType.STRING, newProperty.getType());