public MutablePropertyImpl(String key, String name, Object value, Metadata metadata, Set<Visibility> hiddenVisibilities, Visibility visibility) { if (metadata == null) { metadata = new Metadata(); } this.key = key; this.name = name; this.value = value; this.metadata = metadata; this.visibility = visibility; this.hiddenVisibilities = hiddenVisibilities; }
public MutablePropertyImpl(String key, String name, Object value, Metadata metadata, Set<Visibility> hiddenVisibilities, Visibility visibility) { if (metadata == null) { metadata = new Metadata(); } this.key = key; this.name = name; this.value = value; this.metadata = metadata; this.visibility = visibility; this.hiddenVisibilities = hiddenVisibilities; }
@Override public Metadata getMetadata() { if (cachedMetadata == null) { if (metadata == null) { cachedMetadata = new Metadata(); } else { cachedMetadata = metadata.toMetadata(this.valueSerializer); } } return cachedMetadata; }
/** * Adds or updates a property. * <p/> * The added property will also be indexed in the configured search provider. The type of the value * will determine how it gets indexed. * * @param key The unique key given to the property allowing for multi-valued properties. * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ public ElementBuilder<T> addPropertyValue(String key, String name, Object value, Visibility visibility) { return addPropertyValue(key, name, value, new Metadata(), visibility); }
public ElementMutation<T> addPropertyValue(String key, String name, Object value, Visibility visibility) { return addPropertyValue(key, name, value, new Metadata(), visibility); }
public ElementMutation<T> addPropertyValue(String key, String name, Object value, Visibility visibility) { return addPropertyValue(key, name, value, new Metadata(), visibility); }
/** * Sets or updates a property value. The property key will be set to a constant. This is a convenience method * which allows treating the multi-valued nature of properties as only containing a single value. Care must be * taken when using this method because properties are not only uniquely identified by just key and name but also * visibility so adding properties with the same name and different visibility strings is still permitted. * <p/> * The added property will also be indexed in the configured search provider. The type of the value * will determine how it gets indexed. * * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ public ElementBuilder<T> setProperty(String name, Object value, Visibility visibility) { return setProperty(name, value, new Metadata(), visibility); }
public ElementMutation<T> setProperty(String name, Object value, Visibility visibility) { return setProperty(name, value, new Metadata(), visibility); }
public ElementMutation<T> setProperty(String name, Object value, Visibility visibility) { return setProperty(name, value, new Metadata(), visibility); }
/** * Adds or updates a property. * <p/> * The added property will also be indexed in the configured search provider. The type of the value * will determine how it gets indexed. * * @param key The unique key given to the property allowing for multi-valued properties. * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ public ElementBuilder<T> addPropertyValue(String key, String name, Object value, Visibility visibility) { return addPropertyValue(key, name, value, new Metadata(), visibility); }
/** * Sets or updates a property value. The property key will be set to a constant. This is a convenience method * which allows treating the multi-valued nature of properties as only containing a single value. Care must be * taken when using this method because properties are not only uniquely identified by just key and name but also * visibility so adding properties with the same name and different visibility strings is still permitted. * <p/> * The added property will also be indexed in the configured search provider. The type of the value * will determine how it gets indexed. * * @param name The name of the property. * @param value The value of the property. * @param visibility The visibility to give this property. */ public ElementBuilder<T> setProperty(String name, Object value, Visibility visibility) { return setProperty(name, value, new Metadata(), visibility); }
private Metadata jsonToPropertyMetadata(JSONObject metadataJson) { Metadata metadata = new Metadata(); if (metadataJson == null) { return metadata; } for (Object key : metadataJson.keySet()) { String keyString = (String) key; JSONObject metadataItemJson = metadataJson.getJSONObject(keyString); Object val = jsonStringToObject(metadataItemJson.getString("value")); Visibility visibility = new Visibility(metadataItemJson.getString("visibility")); metadata.add(keyString, val, visibility); } return metadata; }
public Metadata toMetadata(ValueSerializer valueSerializer) { Metadata metadata = new Metadata(); for (Map.Entry<String, Entry> metadataItem : this.entries.entrySet()) { String metadataKey = metadataItem.getValue().getMetadataKey(); Visibility metadataVisibility = metadataItem.getValue().getMetadataVisibility(); Object metadataValue = valueSerializer.valueToObject(metadataItem.getValue().getValue()); if (metadataValue == null) { throw new SecureGraphException("Invalid metadata found."); } metadata.add(metadataKey, metadataValue, metadataVisibility); } return metadata; }
@Test public void testChangePropertyMetadata() { Metadata prop1Metadata = new Metadata(); prop1Metadata.add("prop1_key1", "valueOld", VISIBILITY_EMPTY); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_EMPTY) .setProperty("prop2", "value2", null, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A); v1.prepareMutation() .setPropertyMetadata("prop1", "prop1_key1", "valueNew", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); assertEquals("valueNew", v1.getProperty("prop1").getMetadata().getEntry("prop1_key1", VISIBILITY_EMPTY).getValue()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals("valueNew", v1.getProperty("prop1").getMetadata().getEntry("prop1_key1", VISIBILITY_EMPTY).getValue()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); v1.prepareMutation() .setPropertyMetadata("prop2", "prop2_key1", "valueNew", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); assertEquals("valueNew", v1.getProperty("prop2").getMetadata().getEntry("prop2_key1", VISIBILITY_EMPTY).getValue()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals("valueNew", v1.getProperty("prop2").getMetadata().getEntry("prop2_key1", VISIBILITY_EMPTY).getValue()); }
@Test public void testChangePropertyMetadata() { Metadata prop1Metadata = new Metadata(); prop1Metadata.add("prop1_key1", "valueOld", VISIBILITY_EMPTY); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_EMPTY) .setProperty("prop2", "value2", null, VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A); v1.prepareMutation() .setPropertyMetadata("prop1", "prop1_key1", "valueNew", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); assertEquals("valueNew", v1.getProperty("prop1").getMetadata().getEntry("prop1_key1", VISIBILITY_EMPTY).getValue()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals("valueNew", v1.getProperty("prop1").getMetadata().getEntry("prop1_key1", VISIBILITY_EMPTY).getValue()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); v1.prepareMutation() .setPropertyMetadata("prop2", "prop2_key1", "valueNew", VISIBILITY_EMPTY) .save(AUTHORIZATIONS_A_AND_B); assertEquals("valueNew", v1.getProperty("prop2").getMetadata().getEntry("prop2_key1", VISIBILITY_EMPTY).getValue()); v1 = graph.getVertex("v1", AUTHORIZATIONS_A); assertEquals("valueNew", v1.getProperty("prop2").getMetadata().getEntry("prop2_key1", VISIBILITY_EMPTY).getValue()); }