org.janusgraph.core.Cardinality Java Examples
The following examples show how to use
org.janusgraph.core.Cardinality.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtlasJanusGraphManagement.java From atlas with Apache License 2.0 | 6 votes |
@Override public AtlasPropertyKey makePropertyKey(String propertyName, Class propertyClass, AtlasCardinality cardinality) { if (cardinality.isMany()) { newMultProperties.add(propertyName); } PropertyKeyMaker propertyKeyBuilder = management.makePropertyKey(propertyName).dataType(propertyClass); if (cardinality != null) { Cardinality janusCardinality = AtlasJanusObjectFactory.createCardinality(cardinality); propertyKeyBuilder.cardinality(janusCardinality); } PropertyKey propertyKey = propertyKeyBuilder.make(); return GraphDbObjectFactory.createPropertyKey(propertyKey); }
Example #2
Source File: AtlasJanusGraph.java From atlas with Apache License 2.0 | 6 votes |
public AtlasJanusGraph(JanusGraph graphInstance) { //determine multi-properties once at startup JanusGraphManagement mgmt = null; try { mgmt = graphInstance.openManagement(); Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class); for (PropertyKey key : keys) { if (key.cardinality() != Cardinality.SINGLE) { multiProperties.add(key.name()); } } } finally { if (mgmt != null) { mgmt.rollback(); } } janusGraph = (StandardJanusGraph) graphInstance; }
Example #3
Source File: AtlasJanusObjectFactory.java From atlas with Apache License 2.0 | 5 votes |
/** * Converts a Multiplicity to a Cardinality. * * @param cardinality * @return */ public static Cardinality createCardinality(AtlasCardinality cardinality) { switch(cardinality) { case SINGLE: return Cardinality.SINGLE; case LIST: return Cardinality.LIST; case SET: return Cardinality.SET; default: throw new IllegalStateException("Unrecognized cardinality: " + cardinality); } }
Example #4
Source File: GraphDbObjectFactory.java From atlas with Apache License 2.0 | 5 votes |
/** * Converts a Multiplicity to a Cardinality. * * @param cardinality * @return */ public static AtlasCardinality createCardinality(Cardinality cardinality) { if (cardinality == Cardinality.SINGLE) { return AtlasCardinality.SINGLE; } else if (cardinality == Cardinality.LIST) { return AtlasCardinality.LIST; } return AtlasCardinality.SET; }
Example #5
Source File: GraphContextImpl.java From windup with Eclipse Public License 1.0 | 5 votes |
private PropertyKey getOrCreatePropertyKey(JanusGraphManagement janusGraphManagement, String key, Class<?> dataType, Cardinality cardinality) { PropertyKey propertyKey = janusGraphManagement.getPropertyKey(key); if (propertyKey == null) { propertyKey = janusGraphManagement.makePropertyKey(key).dataType(dataType).cardinality(cardinality).make(); } return propertyKey; }
Example #6
Source File: Solr6Index.java From atlas with Apache License 2.0 | 4 votes |
@Override public String mapKey2Field(String key, KeyInformation keyInfo) { IndexProvider.checkKeyValidity(key); key = key.replace(' ', REPLACEMENT_CHAR); if (!dynFields) return key; if (ParameterType.MAPPED_NAME.hasParameter(keyInfo.getParameters())) return key; String postfix; final Class dataType = keyInfo.getDataType(); if (AttributeUtils.isString(dataType)) { final Mapping map = getStringMapping(keyInfo); switch (map) { case TEXT: postfix = "_t"; break; case STRING: postfix = "_s"; break; default: throw new IllegalArgumentException("Unsupported string mapping: " + map); } } else if (AttributeUtils.isWholeNumber(dataType)) { if (dataType.equals(Long.class)) postfix = "_l"; else postfix = "_i"; } else if (AttributeUtils.isDecimal(dataType)) { if (dataType.equals(Float.class)) postfix = "_f"; else postfix = "_d"; } else if (dataType.equals(BigInteger.class)) { postfix = "_bi"; } else if (dataType.equals(BigDecimal.class)) { postfix = "_bd"; } else if (dataType.equals(Geoshape.class)) { postfix = "_g"; } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { postfix = "_dt"; } else if (dataType.equals(Boolean.class)) { postfix = "_b"; } else if (dataType.equals(UUID.class)) { postfix = "_uuid"; } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { postfix += "s"; } return key+postfix; }