protected StringBuilder createIndexDDLWithFieldType(String indexName, String indexType, String engine) { final StringBuilder ddl = createIndexDDLWithoutFieldType(indexName, indexType,engine); ddl.append(' ').append(keyType.name()); return ddl; }
protected OGlobalProperty findOrCreateGlobalProperty(final String name, final OType type) { OGlobalProperty global = propertiesByNameType.get(name + "|" + type.name()); if (global == null) { int id = properties.size(); global = new OGlobalPropertyImpl(name, type, id); properties.add(id, global); propertiesByNameType.put(global.getName() + "|" + global.getType().name(), global); } return global; }
/** * {@inheritDoc} */ public String toCreateIndexDDL(final String indexName, final String indexType, String engine) { final StringBuilder ddl = new StringBuilder("create index "); ddl.append(indexName).append(" on ").append(className).append(" ( "); final Iterator<String> fieldIterator = getFieldsToIndex().iterator(); if (fieldIterator.hasNext()) { ddl.append(fieldIterator.next()); while (fieldIterator.hasNext()) { ddl.append(", ").append(fieldIterator.next()); } } ddl.append(" ) ").append(indexType).append(' '); if (engine != null) ddl.append(OCommandExecutorSQLCreateIndex.KEYWORD_ENGINE + " " + engine).append(' '); if (multiValueDefinitionIndex == -1) { boolean first = true; for (OType oType : getTypes()) { if (first) first = false; else ddl.append(", "); ddl.append(oType.name()); } } return ddl.toString(); }
public OGlobalProperty createGlobalProperty(final String name, final OType type, final Integer id) { OGlobalProperty global; if (id < properties.size() && (global = properties.get(id)) != null) { if (!global.getName().equals(name) || !global.getType().equals(type)) throw new OSchemaException("A property with id " + id + " already exist "); return global; } global = new OGlobalPropertyImpl(name, type, id); ensurePropertiesSize(id); properties.set(id, global); propertiesByNameType.put(global.getName() + "|" + global.getType().name(), global); return global; }
public void checkPersistentPropertyType(final ODatabaseInternal<ORecord> database, final String propertyName, final OType type) { if (OType.ANY.equals(type)) { return; } final boolean strictSQL = database.getStorage().getConfiguration().isStrictSql(); final StringBuilder builder = new StringBuilder(256); builder.append("select count(*) as count from "); builder.append(getEscapedName(name, strictSQL)); builder.append(" where "); builder.append(getEscapedName(propertyName, strictSQL)); builder.append(".type() not in ["); final Iterator<OType> cur = type.getCastable().iterator(); while (cur.hasNext()) { builder.append('"').append(cur.next().name()).append('"'); if (cur.hasNext()) builder.append(","); } builder.append("] and ").append(getEscapedName(propertyName, strictSQL)).append(" is not null "); if (type.isMultiValue()) builder.append(" and ").append(getEscapedName(propertyName, strictSQL)).append(".size() <> 0 limit 1"); try (final OResultSet res = database.command(builder.toString())) { if (((Long) res.next().getProperty("count")) > 0) throw new OSchemaException("The database contains some schema-less data in the property '" + name + "." + propertyName + "' that is not compatible with the type " + type + ". Fix those records and change the schema again"); } }
@Override public ODocument toDocument() { final ODocument doc = new ODocument(); doc.field("name", name); doc.field("type", type.name()); doc.field("id", id); return doc; } }
.append(oProperty.getName()).append(" : ").append(type.name());
ensurePropertiesSize(prop.getId()); properties.set(prop.getId(), prop); propertiesByNameType.put(prop.getName() + "|" + prop.getType().name(), prop);
public void fireDatabaseMigration(final ODatabaseDocument database, final String propertyName, final OType type) { final boolean strictSQL = ((ODatabaseInternal) database).getStorage().getConfiguration().isStrictSql(); database.query(new OSQLAsynchQuery<Object>( "select from " + getEscapedName(name, strictSQL) + " where " + getEscapedName(propertyName, strictSQL) + ".type() <> \"" + type.name() + "\"", new OCommandResultListener() { @Override public boolean result(Object iRecord) { final ODocument record = ((OIdentifiable) iRecord).getRecord(); record.field(propertyName, record.field(propertyName), type); database.save(record); return true; } @Override public void end() { } @Override public Object getResult() { return null; } })); }
for (ORecordSerializationDebugProperty prop : deserializeDebug.properties) { message("\n property name: %s", prop.name); message("\n property type: %s", prop.type.name()); message("\n property globalId: %d", prop.globalId); message("\n fail on reading: %b", prop.faildToRead);
private ISource createProperty(List<OArchitectOClass> classes, OArchitectOClass oClass, OArchitectOProperty property) { OSourceFragment fragment = new OSourceFragment(); String propName = constantOProperty(oClass.getName(), property.getName()); String type = "OType." + property.getType().name(); String order = "" + property.getOrder(); String linkedClass = property.getLinkedClass(); fragment.addSource(new OSourceChainCall("oProperty", propName, type, order)); if (!property.isInversePropertyEnable() && !Strings.isNullOrEmpty(linkedClass)) { if (isClassContainsIn(linkedClass, classes)) { linkedClass = constantOClass(linkedClass); } else { linkedClass = wrapString(linkedClass); } fragment.addSource(new OSourceChainCall("linkedClass", linkedClass)); } return fragment; }
@Override public void onInitialize(OrienteerWebApplication app, ODatabaseDocument db) { OSchemaHelper helper = OSchemaHelper.bind(db); helper.oClass(TEST_OCLASS); UIVisualizersRegistry registry = app.getUIVisualizersRegistry(); for(OType type: OType.values()) { if(type == OType.LINKBAG) continue; helper.oProperty(type.name().toLowerCase(), type); if(type.isLink()) helper.linkedClass(TEST_OCLASS); for(String vizualization : registry.getComponentsOptions(type)) { helper.oProperty(type.name().toLowerCase()+vizualization, type).assignVisualization(vizualization); if(type.isLink()) helper.linkedClass(TEST_OCLASS); } } }
write(buffer, engineData.keyTypes.length); for (OType type : engineData.keyTypes) { write(buffer, type.name());
private OResultInternal getPropertyAsDocument(final OClass clazz, final OProperty prop) { database.activateOnCurrentThread(); final OType type = prop.getType(); OResultInternal res = new OResultInternal(); res.setProperty("TABLE_CAT", database.getName()); res.setProperty("TABLE_SCHEM", database.getName()); res.setProperty("TABLE_NAME", clazz.getName()); res.setProperty("COLUMN_NAME", prop.getName()); res.setProperty("DATA_TYPE", OrientJdbcResultSetMetaData.getSqlType(type)); res.setProperty("TYPE_NAME", type.name()); res.setProperty("COLUMN_SIZE", 1); res.setProperty("BUFFER_LENGTH", null); res.setProperty("DECIMAL_DIGITS", null); res.setProperty("NUM_PREC_RADIX", 10); res.setProperty("NULLABLE", !prop.isNotNull() ? columnNoNulls : columnNullable); res.setProperty("REMARKS", prop.getDescription()); res.setProperty("COLUMN_DEF", prop.getDefaultValue()); res.setProperty("SQL_DATA_TYPE", null); res.setProperty("SQL_DATETIME_SUB", null); res.setProperty("CHAR_OCTET_LENGTH", null); res.setProperty("ORDINAL_POSITION", prop.getId()); res.setProperty("IS_NULLABLE", prop.isNotNull() ? "NO" : "YES"); return res; }