@Test(expected = IOException.class) public void loadThrowsWhenTypeIsNotSupported() throws IOException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { final Vertex vertex = graph.addVertex(DATABASE_LABEL); final String typeIdentifier = new StringToUnencodedStringOfLimitedValuesConverter(new String[]{}) .getUniqueTypeIdentifier(); vertex.property(CLIENT_PROPERTY_NAME, "clientName"); vertex.property(PROPERTY_TYPE_NAME, typeIdentifier); ReadableProperty.load(vertex, null); }
public static ReadableProperty load(Vertex propertyVertex, String prefix) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { final String type = propertyVertex.value(PROPERTY_TYPE_NAME); if (type.equals(WwDocumentDisplayName.TYPE)) { return new WwDocumentDisplayName(); } else if (type.equals(WwPersonDisplayName.TYPE)) { return new WwPersonDisplayName(); } else if (type.equals(RdfImportedDefaultDisplayname.TYPE)) { return new RdfImportedDefaultDisplayname(); } String[] options = null; if (propertyVertex.property(LocalProperty.OPTIONS_PROPERTY_NAME).isPresent()) { final String optionsJson = propertyVertex.value(LocalProperty.OPTIONS_PROPERTY_NAME); options = new ObjectMapper().readValue(optionsJson, new TypeReference<String[]>() { }); } if (propertyVertex.property(LocalProperty.DATABASE_PROPERTY_NAME).isPresent()) { final String dbName = propertyVertex.value(LocalProperty.DATABASE_PROPERTY_NAME); return new LocalProperty(dbName, Converters.forType(type, options)); } throw new IOException("Unknown property configuration"); }
ReadableProperty { public static ReadableProperty load(Vertex propertyVertex, String prefix) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { final String type = propertyVertex.value(PROPERTY_TYPE_NAME); if (type.equals(WwDocumentDisplayName.TYPE)) { return new WwDocumentDisplayName(); } else if (type.equals(WwPersonDisplayName.TYPE)) { return new WwPersonDisplayName(); } else if (type.equals(RdfImportedDefaultDisplayname.TYPE)) { return new RdfImportedDefaultDisplayname(); } String[] options = null; if (propertyVertex.property(LocalProperty.OPTIONS_PROPERTY_NAME).isPresent()) { final String optionsJson = propertyVertex.value(LocalProperty.OPTIONS_PROPERTY_NAME); options = new ObjectMapper().readValue(optionsJson, new TypeReference<String[]>() { }); } if (propertyVertex.property(LocalProperty.DATABASE_PROPERTY_NAME).isPresent()) { final String dbName = propertyVertex.value(LocalProperty.DATABASE_PROPERTY_NAME); return new LocalProperty(dbName, Converters.forType(type, options)); } throw new IOException("Unknown property configuration"); } }
ReadableProperty { public static ReadableProperty load(Vertex propertyVertex, String prefix) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { final String type = propertyVertex.value(PROPERTY_TYPE_NAME); if (type.equals(WwDocumentDisplayName.TYPE)) { return new WwDocumentDisplayName(); } else if (type.equals(WwPersonDisplayName.TYPE)) { return new WwPersonDisplayName(); } else if (type.equals(RdfImportedDefaultDisplayname.TYPE)) { return new RdfImportedDefaultDisplayname(); } String[] options = null; if (propertyVertex.property(LocalProperty.OPTIONS_PROPERTY_NAME).isPresent()) { final String optionsJson = propertyVertex.value(LocalProperty.OPTIONS_PROPERTY_NAME); options = new ObjectMapper().readValue(optionsJson, new TypeReference<String[]>() { }); } if (propertyVertex.property(LocalProperty.DATABASE_PROPERTY_NAME).isPresent()) { final String dbName = propertyVertex.value(LocalProperty.DATABASE_PROPERTY_NAME); return new LocalProperty(dbName, Converters.forType(type, options)); } throw new IOException("Unknown property configuration"); } ReadableProperty(Supplier<GraphTraversal<?, Try<JsonNode>>> getterJson,
                          Supplier<GraphTraversal<?, Try<Object>>> getterRaw); }
ReadableProperty { public static ReadableProperty load(Vertex propertyVertex, String prefix) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { final String type = propertyVertex.value(PROPERTY_TYPE_NAME); if (type.equals(WwDocumentDisplayName.TYPE)) { return new WwDocumentDisplayName(); } else if (type.equals(WwPersonDisplayName.TYPE)) { return new WwPersonDisplayName(); } else if (type.equals(RdfImportedDefaultDisplayname.TYPE)) { return new RdfImportedDefaultDisplayname(); } String[] options = null; if (propertyVertex.property(LocalProperty.OPTIONS_PROPERTY_NAME).isPresent()) { final String optionsJson = propertyVertex.value(LocalProperty.OPTIONS_PROPERTY_NAME); options = new ObjectMapper().readValue(optionsJson, new TypeReference<String[]>() { }); } if (propertyVertex.property(LocalProperty.DATABASE_PROPERTY_NAME).isPresent()) { final String dbName = propertyVertex.value(LocalProperty.DATABASE_PROPERTY_NAME); return new LocalProperty(dbName, Converters.forType(type, options)); } throw new IOException("Unknown property configuration"); } ReadableProperty(Supplier<GraphTraversal<?, Try<JsonNode>>> getterJson,
                          Supplier<GraphTraversal<?, Try<Object>>> getterRaw); GraphTraversal<?, Try<JsonNode>> traversalJson(); GraphTraversal<?, Try<Object>> traversalRaw(); abstract String getTypeId(); abstract String getUniqueTypeId(); Vertex save(Graph graph, String clientPropertyName); static ReadableProperty load(Vertex propertyVertex, String prefix); }
ReadableProperty { public static ReadableProperty load(Vertex propertyVertex, String prefix) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { final String type = propertyVertex.value(PROPERTY_TYPE_NAME); if (type.equals(WwDocumentDisplayName.TYPE)) { return new WwDocumentDisplayName(); } else if (type.equals(WwPersonDisplayName.TYPE)) { return new WwPersonDisplayName(); } else if (type.equals(RdfImportedDefaultDisplayname.TYPE)) { return new RdfImportedDefaultDisplayname(); } String[] options = null; if (propertyVertex.property(LocalProperty.OPTIONS_PROPERTY_NAME).isPresent()) { final String optionsJson = propertyVertex.value(LocalProperty.OPTIONS_PROPERTY_NAME); options = new ObjectMapper().readValue(optionsJson, new TypeReference<String[]>() { }); } if (propertyVertex.property(LocalProperty.DATABASE_PROPERTY_NAME).isPresent()) { final String dbName = propertyVertex.value(LocalProperty.DATABASE_PROPERTY_NAME); return new LocalProperty(dbName, Converters.forType(type, options)); } throw new IOException("Unknown property configuration"); } ReadableProperty(Supplier<GraphTraversal<?, Try<JsonNode>>> getterJson,
                          Supplier<GraphTraversal<?, Try<Object>>> getterRaw); GraphTraversal<?, Try<JsonNode>> traversalJson(); GraphTraversal<?, Try<Object>> traversalRaw(); abstract String getTypeId(); abstract String getUniqueTypeId(); Vertex save(Graph graph, String clientPropertyName); static ReadableProperty load(Vertex propertyVertex, String prefix); static final String DATABASE_LABEL; static final String DISPLAY_NAME_PROPERTY_NAME; static final String CLIENT_PROPERTY_NAME; static final String PROPERTY_TYPE_NAME; static final String HAS_NEXT_PROPERTY_RELATION_NAME; }