Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *
   *  *  Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com)
   *  *
   *  *  Licensed under the Apache License, Version 2.0 (the "License");
   *  *  you may not use this file except in compliance with the License.
   *  *  You may obtain a copy of the License at
   *  *
   *  *       http://www.apache.org/licenses/LICENSE-2.0
  *  *
  *  *  Unless required by applicable law or agreed to in writing, software
  *  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  *  See the License for the specific language governing permissions and
  *  *  limitations under the License.
  *  *
  *  * For more information: http://www.orientechnologies.com
  *  
  */
 
 package com.tinkerpop.blueprints.impls.orient;
 
 
Base class to manage graph settings.

Author(s):
Luca Garulli (http://www.orientechnologies.com)
 
 public abstract class OrientConfigurableGraph {
   protected Settings             settings                                         = new Settings();
 
   protected static final boolean USE_LIGHTWEIGHT_EDGES_DEFAULT                    = false;
   protected final boolean        USE_CLASS_FOR_EDGE_LABEL_DEFAULT                 = true;
   protected final boolean        USE_CLASS_FOR_VERTEX_LABEL_DEFAULT               = true;
   protected final boolean        KEEP_IN_MEMORY_REFERENCES_DEFAULT                = false;
   protected final boolean        USE_VERTEX_FIELDS_FOR_EDGE_LABELS                = true;
   protected final boolean        SAVE_ORIGINAL_IDS_DEFAULT                        = false;
   protected final boolean        STANDARD_ELEMENT_CONSTRAINTS_DEFAULT             = true;
   protected final boolean        WARN_ON_FORCE_CLOSING_TX_DEFAULT                 = true;
   protected final boolean        AUTO_SCALE_EDGE_TYPE_DEFAULT                     = false;
   protected final int            EDGE_CONTAINER_EMBEDDED_2_TREE_THRESHOLD_DEFAULT = -1;
   protected final int            EDGE_CONTAINER_TREE_2_EMBEDDED_THRESHOLD_DEFAULT = -1;
   protected final THREAD_MODE    THREAD_MODE_DEFAULT                              = .;
   protected final boolean        AUTO_START_TX_DEFAULT                            = true;
   protected final boolean        REQUIRE_TRANSACTION_DEFAULT                      = false;
 
   public enum THREAD_MODE {
     MANUAL, AUTOSET_IFNULL, ALWAYS_AUTOSET
   }
 
   public class Settings {
 
     private Boolean     useLightweightEdges                 = null;
     private Boolean     useClassForEdgeLabel                = null;
     private Boolean     useClassForVertexLabel              = null;
     private Boolean     keepInMemoryReferences              = null;
     private Boolean     useVertexFieldsForEdgeLabels        = null;
     private Boolean     saveOriginalIds                     = null;
     private Boolean     standardElementConstraints          = null;
     private Boolean     warnOnForceClosingTx                = null;
     private Boolean     autoScaleEdgeType                   = null;
     private Integer     edgeContainerEmbedded2TreeThreshold = null;
     private Integer     edgeContainerTree2EmbeddedThreshold = null;
     private THREAD_MODE threadMode                          = null;
     private Boolean     autoStartTx                         = null;
     private Boolean     requireTransaction                  = null;
 
     public Settings copy() {
       final Settings copy = new Settings();
       copy.useLightweightEdges = ;
       copy.useClassForEdgeLabel = ;
       copy.useClassForVertexLabel = ;
       copy.keepInMemoryReferences = ;
       copy.useVertexFieldsForEdgeLabels = ;
       copy.saveOriginalIds = ;
       copy.standardElementConstraints = ;
       copy.warnOnForceClosingTx = ;
       copy.autoScaleEdgeType = ;
       copy.edgeContainerEmbedded2TreeThreshold = ;
       copy.edgeContainerTree2EmbeddedThreshold = ;
       copy.threadMode = ;
       copy.autoStartTx = ;
       copy.requireTransaction = ;
       return copy;
     }

    
copies only not null settings from the input settings object

Parameters:
settings
 
     public void copyFrom(Settings settings) {
       if (settings.useLightweightEdges != null) {
          = settings.useLightweightEdges;
       }
       if (settings.useClassForEdgeLabel != null) {
         = settings.useClassForEdgeLabel;
      }
      if (settings.useClassForVertexLabel != null) {
         = settings.useClassForVertexLabel;
      }
      if (settings.keepInMemoryReferences != null) {
         = settings.keepInMemoryReferences;
      }
      if (settings.useVertexFieldsForEdgeLabels != null) {
         = settings.useVertexFieldsForEdgeLabels;
      }
      if (settings.saveOriginalIds != null) {
         = settings.saveOriginalIds;
      }
      if (settings.standardElementConstraints != null) {
         = settings.standardElementConstraints;
      }
      if (settings.warnOnForceClosingTx != null) {
         = settings.warnOnForceClosingTx;
      }
      if (settings.autoScaleEdgeType != null) {
         = settings.autoScaleEdgeType;
      }
      if (settings.edgeContainerEmbedded2TreeThreshold != null) {
         = settings.edgeContainerEmbedded2TreeThreshold;
      }
      if (settings.edgeContainerTree2EmbeddedThreshold != null) {
         = settings.edgeContainerTree2EmbeddedThreshold;
      }
      if (settings.threadMode != null) {
         = settings.threadMode;
      }
      if (settings.autoStartTx != null) {
         = settings.autoStartTx;
      }
      if (settings.requireTransaction != null) {
         = settings.requireTransaction;
      }
    }

    
Returns true if is using lightweight edges, otherwise false.
    public boolean isUseLightweightEdges() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting about usage of lightweight edges.
    public void setUseLightweightEdges(final boolean useDynamicEdges) {
       = useDynamicEdges;
    }

    
Returns true if is using auto scale edge type, otherwise false.
    public boolean isAutoScaleEdgeType() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting about usage of auto scale edge type.
    public void setAutoScaleEdgeType(final boolean autoScaleEdgeType) {
      this. = autoScaleEdgeType;
    }

    
Returns the minimum number of edges for edge containers to transform the underlying structure from embedded to tree.
      if ( == null) {
      }
    }

    
Changes the minimum number of edges for edge containers to transform the underlying structure from embedded to tree. Use -1 to disable transformation.
    public void setEdgeContainerEmbedded2TreeThreshold(final int edgeContainerEmbedded2TreeThreshold) {
      this. = edgeContainerEmbedded2TreeThreshold;
    }

    
Returns the minimum number of edges for edge containers to transform the underlying structure from tree to embedded.
      if ( == null) {
      }
    }

    
Changes the minimum number of edges for edge containers to transform the underlying structure from tree to embedded. Use -1 to disable transformation.
    public void setEdgeContainerTree2EmbeddedThreshold(final int edgeContainerTree2EmbeddedThreshold) {
      this. = edgeContainerTree2EmbeddedThreshold;
    }

    
Tells if a transaction is started automatically when the graph is changed. This affects only when a transaction hasn't been started. Default is true.

Returns:
    public boolean isAutoStartTx() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
If enabled auto starts a new transaction right before the graph is changed. This affects only when a transaction hasn't been started. Default is true.

Parameters:
autoStartTx
    public void setAutoStartTx(final boolean autoStartTx) {
      this. = autoStartTx;
    }
    public boolean isRequireTransaction() {
      if ( == null) {
        return ;
      }
      return ;
    }
    public void setRequireTransaction(final boolean requireTransaction) {
      this. = requireTransaction;
    }

    
Returns true if it saves the original Id, otherwise false.
    public boolean isSaveOriginalIds() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting about usage of lightweight edges.
    public void setSaveOriginalIds(final boolean saveIds) {
       = saveIds;
    }

    
Returns true if the references are kept in memory.
    public boolean isKeepInMemoryReferences() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting about using references in memory.
    public void setKeepInMemoryReferences(boolean useReferences) {
       = useReferences;
    }

    
Returns true if the class are use for Edge labels.
    public boolean isUseClassForEdgeLabel() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting to use the Edge class for Edge labels.
    public void setUseClassForEdgeLabel(final boolean useCustomClassesForEdges) {
       = useCustomClassesForEdges;
    }

    
Returns true if the class are use for Vertex labels.
    public boolean isUseClassForVertexLabel() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting to use the Vertex class for Vertex labels.
    public void setUseClassForVertexLabel(final boolean useCustomClassesForVertex) {
      this. = useCustomClassesForVertex;
    }

    
Returns true if the out/in fields in vertex are post-fixed with edge labels. This improves traversal time by partitioning edges on different collections, one per Edge's class.
    public boolean isUseVertexFieldsForEdgeLabels() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting to postfix vertices fields with edge labels. This improves traversal time by partitioning edges on different collections, one per Edge's class.
    public void setUseVertexFieldsForEdgeLabels(final boolean useVertexFieldsForEdgeLabels) {
      this. = useVertexFieldsForEdgeLabels;
    }

    
Returns true if Blueprints standard constraints are applied to elements.
    public boolean isStandardElementConstraints() {
      if ( == null) {
      }
      return ;
    }

    
Changes the setting to apply the Blueprints standard constraints against elements.
    public void setStandardElementConstraints(final boolean allowsPropertyValueNull) {
      this. = allowsPropertyValueNull;
    }

    
Returns true if the warning is generated on force the graph closing.
    public boolean isWarnOnForceClosingTx() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the setting to generate a warning if the graph closing has been forced.
    public void setWarnOnForceClosingTx(final boolean warnOnSchemaChangeInTx) {
      this. = warnOnSchemaChangeInTx;
    }

    
Returns the current thread mode:
  • MANUAL the user has to manually invoke the current database in Thread Local: ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
  • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one was set before
  • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local

Returns:
Current Graph instance to allow calls in chain (fluent interface)
See also:
setThreadMode(com.tinkerpop.blueprints.impls.orient.OrientConfigurableGraph.THREAD_MODE)
    public THREAD_MODE getThreadMode() {
      if ( == null) {
        return ;
      }
      return ;
    }

    
Changes the thread mode:
  • MANUAL the user has to manually invoke the current database in Thread Local: ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
  • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one was set before
  • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local

Parameters:
iControl Value to set
Returns:
Current Graph instance to allow calls in chain (fluent interface)
See also:
getThreadMode()
    public void setThreadMode(final THREAD_MODE iControl) {
      this. = iControl;
    }
  }
  protected OrientConfigurableGraph() {
  }
  public abstract void declareIntent(OIntent iIntent);

  
Returns true if is using lightweight edges, otherwise false.
  public boolean isUseLightweightEdges() {
  }

  
Changes the setting about usage of lightweight edges.
  public OrientConfigurableGraph setUseLightweightEdges(final boolean useDynamicEdges) {
    .setUseLightweightEdges(useDynamicEdges);
    return this;
  }

  
Returns true if is using auto scale edge type, otherwise false.
  public boolean isAutoScaleEdgeType() {
    return .isAutoScaleEdgeType();
  }

  
Changes the setting about usage of auto scale edge type.
  public OrientConfigurableGraph setAutoScaleEdgeType(final boolean autoScaleEdgeType) {
    .setAutoScaleEdgeType(autoScaleEdgeType);
    return this;
  }

  
Returns the minimum number of edges for edge containers to transform the underlying structure from embedded to tree.
  }

  
Changes the minimum number of edges for edge containers to transform the underlying structure from embedded to tree. Use -1 to disable transformation.
  public OrientConfigurableGraph setEdgeContainerEmbedded2TreeThreshold(final int edgeContainerEmbedded2TreeThreshold) {
    this..setEdgeContainerEmbedded2TreeThreshold(edgeContainerEmbedded2TreeThreshold);
    return this;
  }

  
Returns the minimum number of edges for edge containers to transform the underlying structure from tree to embedded.
  }

  
Changes the minimum number of edges for edge containers to transform the underlying structure from tree to embedded. Use -1 to disable transformation.
  public OrientConfigurableGraph setEdgeContainerTree2EmbeddedThreshold(final int edgeContainerTree2EmbeddedThreshold) {
    this.. = edgeContainerTree2EmbeddedThreshold;
    return this;
  }

  
Tells if a transaction is started automatically when the graph is changed. This affects only when a transaction hasn't been started. Default is true.

Returns:
  public boolean isAutoStartTx() {
    return .isAutoStartTx();
  }

  
If enabled auto starts a new transaction right before the graph is changed. This affects only when a transaction hasn't been started. Default is true.

Parameters:
autoStartTx
  public void setAutoStartTx(final boolean autoStartTx) {
    this..setAutoStartTx(autoStartTx);
  }
  public boolean isRequireTransaction() {
  }
  public void setRequireTransaction(final boolean requireTransaction) {
    this..setRequireTransaction(requireTransaction);
  }

  
Returns true if it saves the original Id, otherwise false.
  public boolean isSaveOriginalIds() {
    return .isSaveOriginalIds();
  }

  
Changes the setting about usage of lightweight edges.
  public OrientConfigurableGraph setSaveOriginalIds(final boolean saveIds) {
    return this;
  }

  
Returns true if the references are kept in memory.
  public boolean isKeepInMemoryReferences() {
  }

  
Changes the setting about using references in memory.
  public OrientConfigurableGraph setKeepInMemoryReferences(boolean useReferences) {
    .setKeepInMemoryReferences(useReferences);
    return this;
  }

  
Returns true if the class are use for Edge labels.
  public boolean isUseClassForEdgeLabel() {
  }

  
Changes the setting to use the Edge class for Edge labels.
  public OrientConfigurableGraph setUseClassForEdgeLabel(final boolean useCustomClassesForEdges) {
    .setUseClassForEdgeLabel(useCustomClassesForEdges);
    return this;
  }

  
Returns true if the class are use for Vertex labels.
  public boolean isUseClassForVertexLabel() {
  }

  
Changes the setting to use the Vertex class for Vertex labels.
  public OrientConfigurableGraph setUseClassForVertexLabel(final boolean useCustomClassesForVertex) {
    this..setUseClassForVertexLabel(useCustomClassesForVertex);
    return this;
  }

  
Returns true if the out/in fields in vertex are post-fixed with edge labels. This improves traversal time by partitioning edges on different collections, one per Edge's class.
  public boolean isUseVertexFieldsForEdgeLabels() {
  }

  
Changes the setting to postfix vertices fields with edge labels. This improves traversal time by partitioning edges on different collections, one per Edge's class.
  public OrientConfigurableGraph setUseVertexFieldsForEdgeLabels(final boolean useVertexFieldsForEdgeLabels) {
    this..setUseVertexFieldsForEdgeLabels(useVertexFieldsForEdgeLabels);
    return this;
  }

  
Returns true if Blueprints standard constraints are applied to elements.
  public boolean isStandardElementConstraints() {
  }

  
Changes the setting to apply the Blueprints standard constraints against elements.
  public OrientConfigurableGraph setStandardElementConstraints(final boolean allowsPropertyValueNull) {
    this..setStandardElementConstraints(allowsPropertyValueNull);
    return this;
  }

  
Returns true if the warning is generated on force the graph closing.
  public boolean isWarnOnForceClosingTx() {
  }

  
Changes the setting to generate a warning if the graph closing has been forced.
  public OrientConfigurableGraph setWarnOnForceClosingTx(final boolean warnOnSchemaChangeInTx) {
    this..setWarnOnForceClosingTx(warnOnSchemaChangeInTx);
    return this;
  }

  
Returns the current thread mode:
  • MANUAL the user has to manually invoke the current database in Thread Local: ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
  • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one was set before
  • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local

Returns:
Current Graph instance to allow calls in chain (fluent interface)
See also:
setThreadMode(com.tinkerpop.blueprints.impls.orient.OrientConfigurableGraph.THREAD_MODE)
  public THREAD_MODE getThreadMode() {
    return .getThreadMode();
  }

  
Changes the thread mode:
  • MANUAL the user has to manually invoke the current database in Thread Local: ODatabaseRecordThreadLocal.INSTANCE.set(graph.getRawGraph());
  • AUTOSET_IFNULL (default) each call assures the current graph instance is set in the Thread Local only if no one was set before
  • ALWAYS_AUTOSET each call assures the current graph instance is set in the Thread Local

Parameters:
iControl Value to set
Returns:
Current Graph instance to allow calls in chain (fluent interface)
See also:
getThreadMode()
  public OrientConfigurableGraph setThreadMode(final THREAD_MODE iControl) {
    this..setThreadMode(iControl);
    return this;
  }

  
Builds a OrientGraph instance passing a configuration. Supported configuration settings are:
NameDescriptionDefault value
blueprints.orientdb.urlDatabase URL-
blueprints.orientdb.usernameUser nameadmin
blueprints.orientdb.passwordUser passwordadmin
blueprints.orientdb.saveOriginalIdsSaves the original element IDs by using the property origId. This could be useful on import of graph to preserve original idsfalse
blueprints.orientdb.keepInMemoryReferencesAvoid to keep records in memory but only RIDsfalse
blueprints.orientdb.useCustomClassesForEdgesUse Edge's label as OrientDB class. If doesn't exist create it under the hoodtrue
blueprints.orientdb.useCustomClassesForVertexUse Vertex's label as OrientDB class. If doesn't exist create it under the hoodtrue
blueprints.orientdb.useVertexFieldsForEdgeLabelsStore the edge relationships in vertex by using the Edge's class. This allow to use multiple fields and make faster traversal by edge's label (class)true
blueprints.orientdb.lightweightEdgesUses lightweight edges. This avoid to create a physical document per edge. Documents are created only when they have propertiestrue
blueprints.orientdb.autoScaleEdgeTypeSet auto scale of edge type. True means one edge is managed as LINK, 2 or more are managed with a LINKBAGfalse
blueprints.orientdb.edgeContainerEmbedded2TreeThresholdChanges the minimum number of edges for edge containers to transform the underlying structure from embedded to tree. Use -1 to disable transformation-1
blueprints.orientdb.edgeContainerTree2EmbeddedThresholdChanges the minimum number of edges for edge containers to transform the underlying structure from tree to embedded. Use -1 to disable transformation-1

Parameters:
configuration of graph
  protected void init(final Configuration configuration) {
    final Boolean saveOriginalIds = configuration.getBoolean("blueprints.orientdb.saveOriginalIds"null);
    if (saveOriginalIds != null)
      setSaveOriginalIds(saveOriginalIds);
    final Boolean keepInMemoryReferences = configuration.getBoolean("blueprints.orientdb.keepInMemoryReferences"null);
    if (keepInMemoryReferences != null)
      setKeepInMemoryReferences(keepInMemoryReferences);
    final Boolean useCustomClassesForEdges = configuration.getBoolean("blueprints.orientdb.useCustomClassesForEdges"null);
    if (useCustomClassesForEdges != null)
      setUseClassForEdgeLabel(useCustomClassesForEdges);
    final Boolean useCustomClassesForVertex = configuration.getBoolean("blueprints.orientdb.useCustomClassesForVertex"null);
    if (useCustomClassesForVertex != null)
      setUseClassForVertexLabel(useCustomClassesForVertex);
    final Boolean useVertexFieldsForEdgeLabels = configuration.getBoolean("blueprints.orientdb.useVertexFieldsForEdgeLabels"null);
    if (useVertexFieldsForEdgeLabels != null)
      setUseVertexFieldsForEdgeLabels(useVertexFieldsForEdgeLabels);
    final Boolean lightweightEdges = configuration.getBoolean("blueprints.orientdb.lightweightEdges"null);
    if (lightweightEdges != null)
      setUseLightweightEdges(lightweightEdges);
    final Boolean autoScaleEdgeType = configuration.getBoolean("blueprints.orientdb.autoScaleEdgeType"null);
    if (autoScaleEdgeType != null)
      setAutoScaleEdgeType(autoScaleEdgeType);
    final Boolean requireTransaction = configuration.getBoolean("blueprints.orientdb.requireTransaction"null);
    if (requireTransaction != null)
      setRequireTransaction(requireTransaction);
  }
New to GrepCode? Check out our FAQ X