Examples of OClass


Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    return false;
  }

  protected void checkIndexedProperties(final ODocument iRecord) {
    final OClass cls = iRecord.getSchemaClass();
    if (cls == null)
      return;

    OPropertyIndex index;
    for (OProperty prop : cls.getIndexedProperties()) {
      index = prop.getIndex();
      if (index != null)
        index.checkEntry(iRecord);
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    }
  }

  protected Map<OProperty, Object> getIndexedProperties(final ODocument iRecord) {
    final ORecordSchemaAware<?> record = iRecord;
    final OClass cls = record.getSchemaClass();
    if (cls == null)
      return null;

    OPropertyIndex index;
    Object fieldValue;

    Map<OProperty, Object> indexedProperties = null;

    for (OProperty prop : cls.getIndexedProperties()) {
      index = prop.getIndex();
      if (index != null) {
        if (prop.getType() == OType.LINK)
          // GET THE RID TO AVOID LOADING
          fieldValue = record.field(prop.getName(), OType.LINK);
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      iOutput.append(OStringSerializerHelper.CLASS_SEPARATOR);
    }

    OProperty prop;
    OType type;
    OClass linkedClass;
    OType linkedType;
    String fieldClassName;
    int i = 0;

    final String[] fieldNames = iOnlyDelta && record.isTrackingChanges() ? record.getDirtyFields() : record.fieldNames();
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    return iValue != null ? iValue.getClass().getSimpleName() : null;
  }

  private OClass getLinkInfo(final ODatabaseComplex<?> iDatabase, final String iFieldClassName) {
    OClass linkedClass = iDatabase.getMetadata().getSchema().getClass(iFieldClassName);

    if (iDatabase.getDatabaseOwner() instanceof ODatabaseObject) {
      ODatabaseObject dbo = (ODatabaseObject) iDatabase.getDatabaseOwner();
      if (linkedClass == null) {
        Class<?> entityClass = dbo.getEntityManager().getEntityClass(iFieldClassName);
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    String field;
    String fieldName = null;
    String fieldValue;
    OType type = null;
    OClass linkedClass;
    OType linkedType;
    OProperty prop;

    // UNMARSHALL ALL THE FIELDS
    for (int i = 0; i < fields.size(); ++i) {
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    else {
      // CLASS
      if (subjectName.startsWith(OCommandExecutorSQLAbstract.CLASS_PREFIX))
        subjectName = subjectName.substring(OCommandExecutorSQLAbstract.CLASS_PREFIX.length());

      final OClass cls = database.getMetadata().getSchema().getClass(subjectName);
      if (cls == null)
        throw new OCommandSQLParsingException("Class " + subjectName + " not found in database", text, pos);

      className = cls.getName();
    }

    final int beginFields = OStringParser.jumpWhiteSpaces(text, pos);
    if (beginFields == -1 || text.charAt(beginFields) != '(')
      throw new OCommandSQLParsingException("Set of fields is missed. Example: (name, surname)", text, pos);
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      throw new OCommandSQLParsingException("This command supports only the database type ODatabaseDocumentTx and type '"
          + database.getClass() + "' was found");

    final ODatabaseDocumentTx db = (ODatabaseDocumentTx) database.getDatabaseOwner();

    OClass sourceClass = database.getMetadata().getSchema().getClass(sourceClassName);
    if (sourceClass == null)
      throw new OCommandExecutionException("Source class '" + sourceClassName + "' not found");

    OClass destClass = database.getMetadata().getSchema().getClass(destClassName);
    if (destClass == null)
      throw new OCommandExecutionException("Destination class '" + destClassName + "' not found");

    Object value;
    String cmd = "select from " + destClassName + " where " + destField + " = ";
    List<ODocument> result;
    ODocument target;
    Object oldValue;
    long total = 0;

    if (linkName == null)
      // NO LINK NAME EXPRESSED: OVERWRITE THE SOURCE FIELD
      linkName = sourceField;

    boolean inverse = linkType != null && linkType.equalsIgnoreCase("inverse");
    boolean multipleRelationship = false;

    long totRecords = db.countClass(sourceClass.getName());
    long currRecord = 0;

    if (progressListener != null)
      progressListener.onBegin(this, totRecords);

    try {
      // BROWSE ALL THE RECORDS OF THE SOURCE CLASS
      for (ODocument doc : db.browseClass(sourceClass.getName())) {
        value = doc.field(sourceField);

        if (value != null) {
          if (value instanceof ODocument || value instanceof ORID) {
            // ALREADY CONVERTED
          } else if (value instanceof Collection<?>) {
            // TODO
          } else {
            // SEARCH THE DESTINATION RECORD
            target = null;

            if (value instanceof String)
              if (((String) value).length() == 0)
                value = null;
              else
                value = "'" + value + "'";

            result = database.<OCommandRequest> command(new OSQLSynchQuery<ODocument>(cmd + value)).execute();

            if (result == null || result.size() == 0)
              // throw new
              // OCommandExecutionException("Can't create link because the destination record was not found in class '"
              // + destClass.getName() + "' and with the field '" + destField + "' equals to " + value);
              value = null;
            else if (result.size() > 1)
              throw new OCommandExecutionException("Can't create link because multiple records was found in class '"
                  + destClass.getName() + "' with value " + value + " in field '" + destField + "'");
            else {
              target = result.get(0);
              value = target;
            }

            if (target != null && inverse) {
              // INVERSE RELATIONSHIP
              oldValue = target.field(linkName);

              if (oldValue != null) {
                if (!multipleRelationship)
                  multipleRelationship = true;

                Collection<ODocument> coll;
                if (oldValue instanceof Collection) {
                  // ADD IT IN THE EXISTENT COLLECTION
                  coll = (Collection<ODocument>) oldValue;
                  target.setDirty();
                } else {
                  // CREATE A NEW COLLECTION FOR BOTH
                  coll = new ArrayList<ODocument>(2);
                  target.field(linkName, coll);
                  coll.add((ODocument) oldValue);
                }
                coll.add(doc);
              } else {
                target.field(linkName, doc);
              }
              target.save();

            } else {
              // SET THE REFERENCE
              doc.field(linkName, value);
              doc.save();
            }

            total++;
          }
        }

        if (progressListener != null)
          progressListener.onProgress(this, currRecord, currRecord * 100f / totRecords);
      }

      if (total > 0) {
        if (inverse) {
          // REMOVE THE OLD PROPERTY IF ANY
          OProperty prop = destClass.getProperty(linkName);
          if (prop != null)
            destClass.dropProperty(linkName);

          // CREATE THE PROPERTY
          destClass.createProperty(linkName, multipleRelationship ? OType.LINKLIST : OType.LINK, sourceClass);

        } else {

          // REMOVE THE OLD PROPERTY IF ANY
          OProperty prop = sourceClass.getProperty(linkName);
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    if (iClassName.equals(OGraphVertex.class.getSimpleName()))
      return new OGraphVertex(this);
    else if (iClassName.equals(OGraphEdge.class.getSimpleName()))
      return new OGraphEdge(this);

    OClass cls = getMetadata().getSchema().getClass(iClassName);
    if (cls != null) {
      cls = cls.getSuperClass();
      while (cls != null) {
        if (cls.getName().equals(OGraphVertex.class.getSimpleName()))
          return new OGraphVertex(this, iClassName);
        else if (cls.getName().equals(OGraphEdge.class.getSimpleName()))
          return new OGraphEdge(this, iClassName);

        cls = cls.getSuperClass();
      }
    }

    throw new OGraphException("Unrecognized class: " + iClassName);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    registerUserObject(iVertex, iVertex.getDocument());
    return iVertex;
  }

  private void checkForGraphSchema() {
    OClass vertex = underlying.getMetadata().getSchema().getClass(OGraphDatabase.VERTEX_CLASS_NAME);
    OClass edge = underlying.getMetadata().getSchema().getClass(OGraphDatabase.EDGE_CLASS_NAME);

    if (vertex == null) {
      // CREATE THE META MODEL USING THE ORIENT SCHEMA
      vertex = underlying.getMetadata().getSchema()
          .createClass(OGraphDatabase.VERTEX_CLASS_NAME, underlying.addPhysicalCluster(OGraphDatabase.VERTEX_CLASS_NAME));
      edge = underlying.getMetadata().getSchema()
          .createClass(OGraphDatabase.EDGE_CLASS_NAME, underlying.addPhysicalCluster(OGraphDatabase.EDGE_CLASS_NAME));

      edge.createProperty(OGraphDatabase.EDGE_FIELD_IN, OType.LINK, vertex);
      edge.createProperty(OGraphDatabase.EDGE_FIELD_OUT, OType.LINK, vertex);

      vertex.createProperty(OGraphDatabase.VERTEX_FIELD_IN, OType.LINKSET, edge);
      vertex.createProperty(OGraphDatabase.VERTEX_FIELD_OUT, OType.LINKSET, edge);
    } else {
      // @COMPATIBILITY <= 1.0rc4: CHANGE FROM outEdges -> out and inEdges -> in
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      throw new IllegalArgumentException("The document received is not a vertex. Found class '" + iVertex.getSchemaClass() + "'");
  }

  public void checkVertexClass(final String iVertexTypeName) {
    if (iVertexTypeName != null) {
      final OClass cls = getMetadata().getSchema().getClass(iVertexTypeName);
      if (cls == null)
        throw new IllegalArgumentException("The class '" + iVertexTypeName + "' was not found");

      if (!cls.isSubClassOf(vertexBaseClass))
        throw new IllegalArgumentException("The class '" + iVertexTypeName + "' doesn't extend the vertex type");
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.