protected void verifyOption(ConfigOption option) { Preconditions.checkNotNull(option); super.verifyElement(option); if (restriction==Restriction.GLOBAL) Preconditions.checkArgument(option.isGlobal(),"Can only accept global options: %s",option); else if (restriction==Restriction.LOCAL) Preconditions.checkArgument(option.isLocal(),"Can only accept local options: %s",option); }
private static Map<ConfigElement.PathIdentifier, Object> getLocalSubset(Map<ConfigElement.PathIdentifier, Object> m) { return Maps.filterEntries(m, entry -> { assert entry.getKey().element.isOption(); return ((ConfigOption)entry.getKey().element).isLocal(); }); }
@Override public boolean has(ConfigOption option, String... umbrellaElements) { final String key = super.getPath(option, umbrellaElements); return option.isLocal() && local.get(key, option.getDatatype()) != null || option.isGlobal() && global.get(key, option.getDatatype()) != null; }
public void clopen(Object... settings) { config = getConfiguration(); if (mgmt!=null && mgmt.isOpen()) mgmt.rollback(); if (null != tx && tx.isOpen()) tx.commit(); if (settings!=null && settings.length>0) { final Map<TestConfigOption,Object> options = validateConfigOptions(settings); JanusGraphManagement janusGraphManagement = null; final ModifiableConfiguration modifiableConfiguration = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,config, BasicConfiguration.Restriction.LOCAL); for (final Map.Entry<TestConfigOption,Object> option : options.entrySet()) { if (option.getKey().option.isLocal()) { modifiableConfiguration.set(option.getKey().option,option.getValue(),option.getKey().umbrella); } else { if (janusGraphManagement==null) janusGraphManagement = graph.openManagement(); janusGraphManagement.set(ConfigElement.getPath(option.getKey().option,option.getKey().umbrella),option.getValue()); } } if (janusGraphManagement!=null) janusGraphManagement.commit(); modifiableConfiguration.close(); } if (null != graph && null != graph.tx() && graph.tx().isOpen()) graph.tx().commit(); if (null != graph && graph.isOpen()) graph.close(); Preconditions.checkNotNull(config); open(config); }
@Override public<O> O get(ConfigOption<O> option, String... umbrellaElements) { final String key = super.getPath(option,umbrellaElements); Object result = null; if (option.isLocal()) { result = local.get(key,option.getDatatype()); } if (result==null && option.isGlobal()) { result = global.get(key,option.getDatatype()); } return option.get(result); }