/** * {@inheritDoc} * * @param indexName * @param indexType */ public String toCreateIndexDDL(final String indexName, final String indexType, final String engine) { final StringBuilder ddl = new StringBuilder("create index `"); ddl.append(indexName).append("` ").append(indexType).append(' '); if (keyTypes != null && keyTypes.length > 0) { ddl.append(keyTypes[0].toString()); for (int i = 1; i < keyTypes.length; i++) { ddl.append(", ").append(keyTypes[i].toString()); } } return ddl.toString(); }
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, OCommandContext iContext, Object ioResult, Object[] iParams) { if (ioResult == null) { return null; } final OType t = OType.getTypeByValue(ioResult); if (t != null) { return t.toString(); } return null; } }
@Override public OProperty createProperty(final String iPropertyName, final OType iType, final OType iLinkedType) { return graph.executeOutsideTx(new OCallable<OProperty, OrientBaseGraph>() { @Override public OProperty call(final OrientBaseGraph g) { return OrientElementType.super.createProperty(iPropertyName, iType, iLinkedType); } }, "create ", getTypeName(), " property '", iPropertyName, "' as type '", iType.toString(), "' linked type '", iLinkedType.toString(), "'"); }
@Override public OProperty createProperty(final String iPropertyName, final OType iType) { return graph.executeOutsideTx(new OCallable<OProperty, OrientBaseGraph>() { @Override public OProperty call(final OrientBaseGraph g) { return OrientElementType.super.createProperty(iPropertyName, iType); } }, "create ", getTypeName(), " property '", iPropertyName, "' as type '", iType.toString(), "'"); }
@Override public String getColumnTypeName(final int column) throws SQLException { final OResult currentRecord = getCurrentRecord(); String columnLabel = fieldNames[column - 1]; return currentRecord.toElement().getSchemaType() .map(st -> st.getProperty(columnLabel)) .map(p -> p.getType()) .map(t -> t.toString()) .orElse(null); }
@Override public OProperty createProperty(final String iPropertyName, final OType iType, final OClass iLinkedClass) { return graph.executeOutsideTx(new OCallable<OProperty, OrientBaseGraph>() { @Override public OProperty call(final OrientBaseGraph g) { return OrientElementType.super.createProperty(iPropertyName, iType, iLinkedClass); } }, "create ", getTypeName(), " property '", iPropertyName, "' as type '", iType.toString(), "' linked class '", iLinkedClass.getName(), "'"); }
@Override protected void serializeToStream() { super.serializeToStream(); final List<String> keyTypeNames = new ArrayList<String>(keyTypes.length); for (final OType keyType : keyTypes) keyTypeNames.add(keyType.toString()); document.field("keyTypes", keyTypeNames, OType.EMBEDDEDLIST); if (collate instanceof OCompositeCollate) { List<String> collatesNames = new ArrayList<String>(); for (OCollate curCollate : ((OCompositeCollate) this.collate).getCollates()) collatesNames.add(curCollate.getName()); document.field("collates", collatesNames, OType.EMBEDDEDLIST); } else document.field("collate", collate.getName()); document.field("nullValuesIgnored", isNullValuesIgnored()); }
protected void validateType(final IValidatable<T> validatable, final OProperty p, final Object value) { if (value != null) if (OType.convert(value, p.getLinkedType().getDefaultJavaType()) == null) validatable.error(newValidationError("wrongtype", "expectedType", p.getLinkedType().toString())); }
protected void validateType(final IValidatable<T> validatable, final OProperty p, final Object value) { if (value != null) if (OType.convert(value, p.getLinkedType().getDefaultJavaType()) == null) validatable.error(newValidationError("wrongtype", "expectedType", p.getLinkedType().toString())); }
protected void serializeToStream() { super.serializeToStream(); document.field("className", className); document.field("field", field); document.field("keyType", keyType.toString()); document.field("collate", collate.getName()); document.field("nullValuesIgnored", isNullValuesIgnored()); }
public OPropertyImpl setType(final OType type) { getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); final ODatabaseDocumentInternal database = getDatabase(); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand()) { final String cmd = String.format("alter property %s type %s", getFullNameQuoted(), quoteString(type.toString())); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setTypeInternal(type); } else setTypeInternal(type); } finally { releaseSchemaWriteLock(); } owner.fireDatabaseMigration(database, globalRef.getName(), globalRef.getType()); return this; }
public OProperty setLinkedType(final OType linkedType) { getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); checkLinkTypeSupport(getType()); acquireSchemaWriteLock(); try { final ODatabaseDocumentInternal database = getDatabase(); final OStorage storage = database.getStorage(); if (isDistributedCommand()) { final String cmd = String .format("alter property %s linkedtype %s", getFullNameQuoted(), quoteString(linkedType.toString())); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setLinkedTypeInternal(linkedType); } else setLinkedTypeInternal(linkedType); } finally { releaseSchemaWriteLock(); } return this; }
res.setProperty("TYPE_NAME", OType.BINARY.toString()); res.setProperty("DATA_TYPE", Types.BINARY); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.BOOLEAN.toString()); res.setProperty("DATA_TYPE", Types.BOOLEAN); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.BYTE.toString()); res.setProperty("DATA_TYPE", Types.TINYINT); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.DATE.toString()); res.setProperty("DATA_TYPE", Types.DATE); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.DATETIME.toString()); res.setProperty("DATA_TYPE", Types.DATE); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.DECIMAL.toString()); res.setProperty("DATA_TYPE", Types.DECIMAL); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.FLOAT.toString()); res.setProperty("DATA_TYPE", Types.FLOAT); res.setProperty("NULLABLE", DatabaseMetaData.typeNullable); res.setProperty("TYPE_NAME", OType.DOUBLE.toString());
writer.beginObject(5, true, null); writer.writeAttribute(0, false, "name", p.getName()); writer.writeAttribute(0, false, "type", p.getType().toString()); if (p.isMandatory()) writer.writeAttribute(0, false, "mandatory", p.isMandatory()); writer.writeAttribute(0, false, "linked-class", p.getLinkedClass().getName()); if (p.getLinkedType() != null) writer.writeAttribute(0, false, "linked-type", p.getLinkedType().toString()); if (p.getMin() != null) writer.writeAttribute(0, false, "min", p.getMin());