private OType[] calculateKeyTypes(OCommandContext ctx) { if (keyTypes == null) { return new OType[0]; } return keyTypes.stream().map(x -> OType.valueOf(x.getStringValue())).collect(Collectors.toList()).toArray(new OType[] {}); }
@Override public void fromDocument(final ODocument document) { this.name = document.field("name"); this.type = OType.valueOf((String) document.field("type")); this.id = document.field("id"); }
@Override public Object execute(Object iThis, OIdentifiable iCurrentRecord, OCommandContext iContext, Object ioResult, Object[] iParams) { if (iThis == null || iParams[0] == null) { return null; } final String destType = iParams[0].toString(); if (destType.contains(".")) { try { return OType.convert(iThis, Class.forName(destType)); } catch (ClassNotFoundException e) { OLogManager.instance().error(this, "Class for destination type was not found", e); } } else { final OType orientType = OType.valueOf(destType.toUpperCase(Locale.ENGLISH)); if (orientType != null) { return OType.convert(iThis, orientType.getDefaultJavaType()); } } return null; } }
private static OArchitectOProperty convertInverseProperty(JSONObject jsonObject) { String name = !jsonObject.isNull(NAME) ? jsonObject.getString(NAME) : null; OType type = !jsonObject.isNull(TYPE) ? OType.valueOf(jsonObject.getString(TYPE)) : null; return !Strings.isNullOrEmpty(name) && type != null ? new OArchitectOProperty(name, type) : null; } }
@Override public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) { super.configure(iProcessor, iConfiguration, iContext); joinValue = iConfiguration.field("joinValue"); linkFieldName = iConfiguration.field("linkFieldName"); if (iConfiguration.containsField("linkFieldType")) linkFieldType = OType.valueOf((String) iConfiguration.field("linkFieldType")); }
columnTypes.add(OType.valueOf(parts[1].toUpperCase())); else columnTypes.add(OType.ANY);
@Override public void configure(final ODocument iConfiguration, OCommandContext iContext) { super.configure(iConfiguration, iContext); joinValue = iConfiguration.field("joinValue"); linkFieldName = iConfiguration.field("linkFieldName"); if (iConfiguration.containsField("linkFieldType")) linkFieldType = OType.valueOf((String) iConfiguration.field("linkFieldType")); }
type = OType.valueOf(word.toString());
protected void serializeFromStream() { super.serializeFromStream(); className = document.field("className"); field = document.field("field"); final String keyTypeStr = document.field("keyType"); keyType = OType.valueOf(keyTypeStr); setCollate((String) document.field("collate")); setNullValuesIgnored(!Boolean.FALSE.equals(document.<Boolean> field("nullValuesIgnored"))); }
private OIndex<?> getoIndex(OClass oClass, String[] fields, String engine, ODatabase database, List<OCollate> collatesList, ODocument metadataDoc) { OIndex<?> idx; if ((keyTypes == null || keyTypes.size() == 0) && collatesList == null) { idx = oClass.createIndex(name.getValue(), type.getStringValue(), null, metadataDoc, engine, fields); } else { final List<OType> fieldTypeList; if (keyTypes == null || keyTypes.size() == 0 && fields.length > 0) { for (final String fieldName : fields) { if (!fieldName.equals("@rid") && !oClass.existsProperty(fieldName)) throw new OIndexException( "Index with name : '" + name.getValue() + "' cannot be created on class : '" + oClass.getName() + "' because field: '" + fieldName + "' is absent in class definition."); } fieldTypeList = ((OClassImpl) oClass).extractFieldTypes(fields); } else fieldTypeList = keyTypes.stream().map(x -> OType.valueOf(x.getStringValue())).collect(Collectors.toList()); final OIndexDefinition idxDef = OIndexDefinitionFactory .createIndexDefinition(oClass, Arrays.asList(fields), fieldTypeList, collatesList, type.getStringValue(), null); idx = database.getMetadata().getIndexManager() .createIndex(name.getValue(), type.getStringValue(), idxDef, oClass.getPolymorphicClusterIds(), null, metadataDoc, engine); } return idx; }
if (keyTypeStr == null) throw new OIndexException("Cannot convert from old index model to new one. " + "Index key type is absent"); final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH)); } else if (config.field(OIndexInternal.CONFIG_KEYTYPE) != null) { final String keyTypeStr = config.field(OIndexInternal.CONFIG_KEYTYPE); final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH));
indexType = p.getValue().toString().toUpperCase(Locale.ENGLISH); else if (p.getKey().equals("keytype")) keyType = OType.valueOf(p.getValue().toString().toUpperCase(Locale.ENGLISH)); else if (p.getKey().equals("class")) className = p.getValue().toString();
@Override protected void serializeFromStream() { super.serializeFromStream(); final List<String> keyTypeNames = document.field("keyTypes"); keyTypes = new OType[keyTypeNames.size()]; int i = 0; for (final String keyTypeName : keyTypeNames) { keyTypes[i] = OType.valueOf(keyTypeName); i++; } String collate = document.field("collate"); if (collate != null) { setCollate(collate); } else { final List<String> collatesNames = document.field("collates"); if( collatesNames != null ) { OCompositeCollate collates = new OCompositeCollate(this); for (String collateName : collatesNames) collates.addCollate(OSQLEngine.getCollate(collateName)); this.collate = collates; } } setNullValuesIgnored(!Boolean.FALSE.equals(document.<Boolean>field("nullValuesIgnored"))); }
indexType = p.getValue().toString().toUpperCase(); else if (p.getKey().equals("keytype")) keyType = OType.valueOf(p.getValue().toString().toUpperCase()); else if (p.getKey().equals("class")) className = p.getValue().toString();
columnNames.add(col2Type[0]); if (col2Type.length > 1) { columnTypes.put(col2Type[0], OType.valueOf(col2Type[1].toUpperCase(Locale.ENGLISH))); } else { columnTypes.put(col2Type[0], OType.ANY);
"Property " + className.getStringValue() + "." + propertyName.getStringValue() + " already exists"); OType type = OType.valueOf(propertyType.getStringValue().toUpperCase(Locale.ENGLISH)); if (type == null) { throw new OCommandExecutionException("Invalid property type: " + propertyType.getStringValue()); if (linkedClass == null) linkedType = OType.valueOf(linked.toUpperCase(Locale.ENGLISH));
private static OArchitectOProperty convertOPropertyFromJson(JSONObject jsonObject) { String name = !jsonObject.isNull(NAME) ? jsonObject.getString(NAME) : null; OType type = !jsonObject.isNull(TYPE) ? OType.valueOf(jsonObject.getString(TYPE)) : null; OArchitectOProperty property = null; if (!Strings.isNullOrEmpty(name) && type != null) { property = new OArchitectOProperty(name, type); if (!jsonObject.isNull(SUBCLASS_PROPERTY)) { String subClassProperty = jsonObject.getString(SUBCLASS_PROPERTY); property.setSubClassProperty(subClassProperty.equals("1") || subClassProperty.equals("true")); } if (!jsonObject.isNull(LINKED_CLASS_NAME)) { property.setLinkedClass(jsonObject.getString(LINKED_CLASS_NAME)); } if (!jsonObject.isNull(ORDER)) { property.setOrder(jsonObject.getInt(ORDER)); } if (!jsonObject.isNull(INVERSE_PROPERY_ENABLE)) { property.setInversePropertyEnable(jsonObject.getBoolean(INVERSE_PROPERY_ENABLE)); if (!jsonObject.isNull(INVERSE_PROPERTY)) { property.setInverseProperty(convertInverseProperty(jsonObject.getJSONObject(INVERSE_PROPERTY))); } } } return property; }
linkedType = OType.valueOf(linked.toUpperCase(Locale.ENGLISH));
/** * {@inheritDoc} * Create a new class of OrientDB documents if necessary. Enforce specified schema over the document class. * */ @Override public void createSchema() throws GoraException { if (schemaExists()) { return; } try (ODatabaseDocumentTx schemaTx = connectionPool.acquire()) { schemaTx.activateOnCurrentThread(); OClass documentClass = schemaTx.getMetadata().getSchema().createClass(orientDBMapping.getDocumentClass()); documentClass.createProperty("_id", OType.getTypeByClass(super.getKeyClass())).createIndex(OClass.INDEX_TYPE.UNIQUE); for (String docField : orientDBMapping.getDocumentFields()) { documentClass.createProperty(docField, OType.valueOf(orientDBMapping.getDocumentFieldType(docField).name())); } schemaTx.getMetadata().getSchema().reload(); } catch (Exception e) { throw new GoraException(e); } }