@Override public OProperty setMandatory(final boolean mandatory) { delegate.setMandatory(mandatory); return this; }
@Override protected void defineType(final OClass type) { type.createProperty(P_ID, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_ALIAS, OType.STRING) .setMandatory(false) .setNotNull(false); }
@Override protected void defineType(final OClass type) { type.createProperty(P_NAME, OType.STRING).setMandatory(true).setMax(MAX_NAME_LENGTH).setNotNull(true); type.createProperty(P_NOTES, OType.STRING).setMandatory(false).setNotNull(false); type.createProperty(P_FORMAT, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_MODE, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_CRITERIA, OType.EMBEDDEDMAP).setMandatory(true).setNotNull(true); type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME); type.createIndex(I_FORMAT, INDEX_TYPE.NOTUNIQUE, P_FORMAT); }
@Override protected void defineType(final OClass type) { type.createProperty(P_NAME, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_TYPE, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_DESCRIPTION, OType.STRING); type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP) .setMandatory(true) .setNotNull(true); type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME); }
@Override protected void defineType(final OClass type) { type.createProperty(P_APIKEY, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_DOMAIN, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_PRIMARY_PRINCIPAL, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_PRINCIPALS, OType.BINARY) .setMandatory(true) .setNotNull(true); type.createIndex(I_APIKEY, INDEX_TYPE.UNIQUE, P_DOMAIN, P_APIKEY); type.createIndex(I_PRIMARY_PRINCIPAL, INDEX_TYPE.UNIQUE, P_DOMAIN, P_PRIMARY_PRINCIPAL); }
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); } }
@Override protected void defineType(final OClass type) { type.createProperty(P_REPOSITORY_NAME, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_ASSET_NAME, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_NODE_ID, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_COUNT, OType.LONG).setMandatory(true).setNotNull(true); type.createProperty(P_DATE_TYPE, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_DATE, OType.DATETIME).setMandatory(true).setNotNull(true); type.createIndex(I_REPO_NAME_ASSET_NAME_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_REPOSITORY_NAME, P_ASSET_NAME, P_DATE_TYPE, P_DATE); type.createIndex(I_NODE_ID_REPO_NAME_ASSET_NAME_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_NODE_ID, P_REPOSITORY_NAME, P_ASSET_NAME, P_DATE_TYPE, P_DATE); type.createIndex(I_NODE_ID_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_NODE_ID, P_DATE_TYPE, P_DATE); type.createIndex(I_REPO_NAME_DATE_TYPE_DATE, INDEX_TYPE.NOTUNIQUE, P_REPOSITORY_NAME, P_DATE_TYPE); }
@Override protected void defineType(final OClass type) { type.createProperty(P_NAME, OType.STRING) .setCollate(new OCaseInsensitiveCollate()) .setMandatory(true) .setNotNull(true); type.createProperty(P_TYPE, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP) .setMandatory(true) .setNotNull(true); type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME); }
@Override protected void defineType(final OClass type) { type.createProperty(P_NODE_ID, OType.STRING) .setCollate(new OCaseInsensitiveCollate()) .setMandatory(true) .setNotNull(true); type.createProperty(P_LAST_HEALTHCHECK, OType.DATETIME) .setMandatory(true) .setNotNull(true); type.createIndex(I_NODE_ID, INDEX_TYPE.UNIQUE, P_NODE_ID); }
private void createCaseInsensitiveNameField(final OClass type) { log.info("Creating case-insensitive name field on component"); if (!type.existsProperty(P_CI_NAME)) { type.createProperty(P_CI_NAME, OType.STRING) .setCollate(new OCaseInsensitiveCollate()) .setMandatory(false) .setNotNull(false); } }
@Override protected void defineType(final OClass type) { type.createProperty(P_BUCKET, OType.LINK, bucketEntityAdapter.getSchemaType()).setMandatory(true).setNotNull(true); type.createProperty(P_FORMAT, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_LAST_UPDATED, OType.DATETIME); type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP); }
@Override protected void defineType(final OClass type) { type.createProperty(P_REPOSITORY_NAME, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_PARENT_PATH, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_NAME, OType.STRING).setMandatory(true).setNotNull(true); type.createProperty(P_COMPONENT_ID, OType.LINK, componentEntityAdapter.getSchemaType()); type.createProperty(P_ASSET_ID, OType.LINK, assetEntityAdapter.getSchemaType()); type.createProperty(P_ASSET_NAME_LOWERCASE, OType.STRING); }
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final Field field, final Mandatory annotation) { final String name = field.getName(); final boolean mandatory = annotation.value(); final OProperty property = db.getMetadata().getSchema() .getClass(descriptor.schemeClass).getProperty(name); if (property.isMandatory() != mandatory) { property.setMandatory(mandatory); logger.debug("Set {}.{} property mandatory={}", descriptor.schemeClass, name, mandatory); } } }
@Override protected void defineType(final OClass type) { type.createProperty(P_REPOSITORY_NAME, OType.STRING) .setCollate(new OCaseInsensitiveCollate()) .setMandatory(true) .setNotNull(true); type.createProperty(P_RECIPE_NAME, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_ONLINE, OType.BOOLEAN) .setMandatory(true) .setNotNull(true); type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP); type.createIndex(I_REPOSITORY_NAME, INDEX_TYPE.UNIQUE, P_REPOSITORY_NAME); }
@Override protected void defineType(final OClass type) { type.createProperty(P_REPOSITORY_NAME, OType.STRING) .setMandatory(true) .setNotNull(true); type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP) .setNotNull(true); type.createIndex(I_REPOSITORY_NAME, INDEX_TYPE.UNIQUE, P_REPOSITORY_NAME); }
@Override protected void defineType(final OClass type) { type.createProperty(P_ENABLED, OType.BOOLEAN) .setMandatory(true) .setNotNull(true); type.createProperty(P_USER_ID, OType.STRING) .setNotNull(true); type.createProperty(P_REALM_NAME, OType.STRING) .setNotNull(true); }
public void create(ODatabaseDocumentInternal database) { if (database.getMetadata().getSchema().existsClass(OScheduledEvent.CLASS_NAME)) return; final OClass f = database.getMetadata().getSchema().createClass(OScheduledEvent.CLASS_NAME); f.createProperty(OScheduledEvent.PROP_NAME, OType.STRING, (OType) null, true).setMandatory(true).setNotNull(true); f.createProperty(OScheduledEvent.PROP_RULE, OType.STRING, (OType) null, true).setMandatory(true).setNotNull(true); f.createProperty(OScheduledEvent.PROP_ARGUMENTS, OType.EMBEDDEDMAP, (OType) null, true); f.createProperty(OScheduledEvent.PROP_STATUS, OType.STRING, (OType) null, true); f.createProperty(OScheduledEvent.PROP_FUNC, OType.LINK, database.getMetadata().getSchema().getClass(OFunction.CLASS_NAME), true) .setMandatory(true).setNotNull(true); f.createProperty(OScheduledEvent.PROP_STARTTIME, OType.DATETIME, (OType) null, true); }
private void createProperty(OClass oClass, FieldDefinition field) { OProperty oProperty = oClass.createProperty(field.getName(), OTYPES.get(field.getType())); if (field.isNotNull()) { oProperty.setNotNull(true); oProperty.setMandatory(true); } if (field.isIndexed()) { final String indexName = String.format("%s.%s", oClass.getName(), field.getName()); oClass.createIndex(indexName, field.isUnique() ? INDEX_TYPE.UNIQUE : INDEX_TYPE.NOTUNIQUE, field.getName()); } }
private void createOrUpdateOUserClass(final ODatabaseDocument database, OClass identityClass, OClass roleClass) { boolean unsafe = false; OClass userClass = database.getMetadata().getSchema().getClass("OUser"); if (userClass == null) { userClass = database.getMetadata().getSchema().createClass("OUser", identityClass); unsafe = true; } else if (!userClass.getSuperClasses().contains(identityClass)) // MIGRATE AUTOMATICALLY TO 1.2.0 userClass.setSuperClasses(Arrays.asList(identityClass)); if (!userClass.existsProperty("name")) { ((OClassImpl) userClass).createProperty("name", OType.STRING, (OType) null, unsafe).setMandatory(true).setNotNull(true) .setCollate("ci").setMin("1").setRegexp("\\S+(.*\\S+)*"); userClass.createIndex("OUser.name", INDEX_TYPE.UNIQUE, ONullOutputListener.INSTANCE, "name"); } else { final OProperty name = userClass.getProperty("name"); if (name.getAllIndexes().isEmpty()) userClass.createIndex("OUser.name", INDEX_TYPE.UNIQUE, ONullOutputListener.INSTANCE, "name"); } if (!userClass.existsProperty(OUser.PASSWORD_FIELD)) userClass.createProperty(OUser.PASSWORD_FIELD, OType.STRING, (OType) null, unsafe).setMandatory(true).setNotNull(true); if (!userClass.existsProperty("roles")) userClass.createProperty("roles", OType.LINKSET, roleClass, unsafe); if (!userClass.existsProperty("status")) userClass.createProperty("status", OType.STRING, (OType) null, unsafe).setMandatory(true).setNotNull(true); }
private OClass createOrUpdateORoleClass(final ODatabaseDocument database, OClass identityClass) { OClass roleClass = database.getMetadata().getSchema().getClass("ORole"); boolean unsafe = false; if (roleClass == null) { roleClass = database.getMetadata().getSchema().createClass("ORole", identityClass); unsafe = true; } else if (!roleClass.getSuperClasses().contains(identityClass)) // MIGRATE AUTOMATICALLY TO 1.2.0 roleClass.setSuperClasses(Arrays.asList(identityClass)); if (!roleClass.existsProperty("name")) { roleClass.createProperty("name", OType.STRING, (OType) null, unsafe).setMandatory(true).setNotNull(true).setCollate("ci"); roleClass.createIndex("ORole.name", INDEX_TYPE.UNIQUE, ONullOutputListener.INSTANCE, "name"); } else { final OProperty name = roleClass.getProperty("name"); if (name.getAllIndexes().isEmpty()) roleClass.createIndex("ORole.name", INDEX_TYPE.UNIQUE, ONullOutputListener.INSTANCE, "name"); } if (!roleClass.existsProperty("mode")) roleClass.createProperty("mode", OType.BYTE, (OType) null, unsafe); if (!roleClass.existsProperty("rules")) roleClass.createProperty("rules", OType.EMBEDDEDMAP, OType.BYTE, unsafe); if (!roleClass.existsProperty("inheritedRole")) roleClass.createProperty("inheritedRole", OType.LINK, roleClass, unsafe); return roleClass; }