/** * Create an instance of {@link KeyType } * */ public KeyType createKeyType() { return new KeyType(); }
/** * Create an instance of {@link KeyType } * */ public KeyType createKeyType() { return new KeyType(); }
private static void addProperties(GraphmlType graphmlType, KeyForType keyForType, GraphMLElement element, DataTypeAddCallback callback) throws InvalidGraphException { for (Map.Entry<String, Object> eachEntry : element.getProperties().entrySet()) { if (eachEntry.getKey().equals(GraphMLElement.ID)) { // skip IDs continue; } List<KeyType> definedKeys = graphmlType.getKey().stream() .filter(eachKey -> eachKey.getFor() == keyForType) .filter(eachKey -> eachKey.getId().equals(eachEntry.getKey())) .collect(Collectors.toList()); if (definedKeys.isEmpty()) { KeyType keyType = new KeyType(); keyType.setFor(keyForType); keyType.setId(eachEntry.getKey()); keyType.setAttrName(eachEntry.getKey()); keyType.setAttrType(parseType(eachEntry.getValue())); graphmlType.getKey().add(keyType); } if (definedKeys.size() > 1) { throw new InvalidGraphException("Duplicate key found for id " + eachEntry.getKey()); } DataType dataType = new DataType(); dataType.setKey(eachEntry.getKey()); dataType.setContent(String.valueOf(eachEntry.getValue())); callback.addData(dataType); } }
@Override protected GraphmlType getTransformation() { final GraphmlType graphmlType = new GraphmlType(); for (final String key : this.nodeKeys) { final KeyType keyType = new KeyType(); keyType.setId(key); keyType.setFor(KeyForType.NODE); keyType.setAttrName(key); keyType.setAttrType(KeyTypeType.STRING); graphmlType.getKey().add(keyType); } for (final String key : this.edgeKeys) { final KeyType keyType = new KeyType(); keyType.setId(key); keyType.setFor(KeyForType.EDGE); keyType.setAttrName(key); keyType.setAttrType(KeyTypeType.STRING); graphmlType.getKey().add(keyType); } graphmlType.getGraphOrData().add(this.graphType); return graphmlType; }