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

The following examples show how to use com.orientechnologies.orient.core.metadata.schema.OClass#existsProperty() . 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: ComponentDatabaseUpgrade_1_5.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
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);
  }
}
 
Example 2
Source File: ComponentDatabaseUpgrade_1_3.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private void renameAssetLastAccessedField() {
  try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) {
    OClass assetClass = getAssetDbClass(db);
    if (assetClass.existsProperty(P_LAST_ACCESSED)) {
      db.command(new OCommandSQL(ALTER_ASSET_LAST_ACCESSED)).execute();
    }
  }
}
 
Example 3
Source File: OWidgetsModule.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
protected void installWidgetsSchemaV3(ODatabaseDocument db) {
	OSchemaHelper helper = OSchemaHelper.bind(db);
	OClass widgetClass = helper.oClass(OCLASS_WIDGET).getOClass();
	if(!widgetClass.existsProperty(OPROPERTY_TITLE)) {
		db.command(new OSQLSynchQuery<Void>("UPDATE "+OCLASS_WIDGET+" REMOVE title"));
	}
	OClass classToFix = db.getMetadata().getSchema()
					.getClass(AbstractHtmlJsPaneWidget.WIDGET_OCLASS_NAME);
	if(classToFix!=null && classToFix.existsProperty("title") && !widgetClass.existsProperty("title")) classToFix.dropProperty("title");
	
	helper.oClass(OCLASS_WIDGET)
		.oProperty(OPROPERTY_TITLE, OType.EMBEDDEDMAP, 0).assignVisualization("localization");
}
 
Example 4
Source File: ComponentDatabaseUpgrade_1_3.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
private void maybeCreateProperty(final OClass oClass, final String property, final OType oType) {
  if (!oClass.existsProperty(property)) {
    oClass.createProperty(property, oType);
  }
}