public PropertiesGlobalModelContext(Properties props) {
    this.properties = props;

    environmentName = props.getProperty(PROPERTY_ENVIRONMENT_NAME);
    currentRegion = props.getProperty(PROPERTY_CURRENT_REGION);
    applicationVersion = props.getProperty(PROPERTY_APPLICATION_VERSION);
    applicationName = props.getProperty(PROPERTY_APPLICATION_NAME);
    isLocal = Boolean.parseBoolean(props.getProperty(PROPERTY_IS_LOCAL, "false"));
    homePageUrl = props.getProperty(PROPERTY_HOME_PAGE);
    defaultPort = Short.parseShort(props.getProperty(PROPERTY_DEFAULT_PORT, "8080"));
    dataCenter = props.getProperty(PROPERTY_DATA_CENTER);
    defaultExplorerName = props.getProperty(PROPERTY_DEFAULT_EXPLORER);

    try {
      Map<Object, Object> dcs =
          ConfigurationConverter.getMap(
              ConfigurationConverter.getConfiguration(props).subset(PROPERTIES_PREFIX + ".dc"));
      for (Entry<Object, Object> dc : dcs.entrySet()) {
        String key = StringUtils.substringBefore(dc.getKey().toString(), ".");
        String attr = StringUtils.substringAfter(dc.getKey().toString(), ".");

        CrossLink link = links.get(key);
        if (link == null) {
          link = new CrossLink();
          links.put(key, link);
        }

        BeanUtils.setProperty(link, attr, dc.getValue());
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Esempio n. 2
0
  /**
   * Two calculators are equal when have the same configuration.
   *
   * @param obj the calculator to compare on
   * @return true if the calculators are equal, false otherwise
   */
  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof LogicTreeProcessor)) {
      return false;
    }

    LogicTreeProcessor other = (LogicTreeProcessor) obj;

    Properties thisConfig = ConfigurationConverter.getProperties(config);

    Properties otherConfig = ConfigurationConverter.getProperties(other.config);

    return thisConfig.equals(otherConfig);
  }
Esempio n. 3
0
 private Neo4jGraph(final Configuration configuration) {
   try {
     this.configuration.copy(EMPTY_CONFIGURATION);
     this.configuration.copy(configuration);
     final String directory = this.configuration.getString(CONFIG_DIRECTORY);
     final Map neo4jSpecificConfig =
         ConfigurationConverter.getMap(this.configuration.subset(CONFIG_CONF));
     final boolean ha = this.configuration.getBoolean(CONFIG_HA, false);
     // if HA is enabled then use the correct factory to instantiate the GraphDatabaseService
     this.baseGraph =
         ha
             ? new HighlyAvailableGraphDatabaseFactory()
                 .newHighlyAvailableDatabaseBuilder(directory)
                 .setConfig(neo4jSpecificConfig)
                 .newGraphDatabase()
             : new GraphDatabaseFactory()
                 .newEmbeddedDatabaseBuilder(directory)
                 .setConfig(neo4jSpecificConfig)
                 .newGraphDatabase();
     this.transactionManager =
         ((GraphDatabaseAPI) this.baseGraph)
             .getDependencyResolver()
             .resolveDependency(TransactionManager.class);
     this.cypher = new ExecutionEngine(this.baseGraph);
     this.neo4jGraphVariables = new Neo4jGraphVariables(this);
     ///////////
     if (!this.neo4jGraphVariables.get(Graph.System.system(CONFIG_META_PROPERTIES)).isPresent())
       this.neo4jGraphVariables.set(
           Graph.System.system(CONFIG_META_PROPERTIES),
           this.configuration.getBoolean(CONFIG_META_PROPERTIES, false));
     // TODO: Logger saying the configuration properties are ignored if already in Graph.Variables
     if (!this.neo4jGraphVariables.get(Graph.System.system(CONFIG_MULTI_PROPERTIES)).isPresent())
       this.neo4jGraphVariables.set(
           Graph.System.system(CONFIG_MULTI_PROPERTIES),
           this.configuration.getBoolean(CONFIG_MULTI_PROPERTIES, false));
     // TODO: Logger saying the configuration properties are ignored if already in Graph.Variables
     this.supportsMetaProperties =
         this.neo4jGraphVariables.<Boolean>get(Graph.System.system(CONFIG_META_PROPERTIES)).get();
     this.supportsMultiProperties =
         this.neo4jGraphVariables.<Boolean>get(Graph.System.system(CONFIG_MULTI_PROPERTIES)).get();
     if ((this.supportsMetaProperties && !this.supportsMultiProperties)
         || (!this.supportsMetaProperties && this.supportsMultiProperties)) {
       tx().rollback();
       throw new UnsupportedOperationException(
           "Neo4jGraph currently requires either both meta- and multi-properties activated or neither activated");
     }
     tx().commit();
     ///////////
   } catch (Exception e) {
     if (this.baseGraph != null) this.baseGraph.shutdown();
     throw new RuntimeException(e.getMessage(), e);
   }
 }
Esempio n. 4
0
  /**
   * Create LogicTreeProcessor by loading a job configuration from the available KVS. The
   * configuration file is serialized as JSON.
   *
   * @param cache - KVS connection
   * @param key - key used to retrieve the job config from the KVS
   */
  public LogicTreeProcessor(Cache cache, String key) {
    kvs = cache;
    Properties properties = new Gson().fromJson((String) cache.get(key), Properties.class);

    config = ConfigurationConverter.getConfiguration(properties);
  }
Esempio n. 5
0
 public LogicTreeProcessor(Properties p) {
   config = ConfigurationConverter.getConfiguration(p);
 }