public RemovePropertyEvent(Graph graph, Element element, Property property) { super(graph); this.element = element; this.key = property.getKey(); this.name = property.getName(); this.visibility = property.getVisibility(); }
public static JSONObject propertyYoJson(Property property) { JSONObject json = new JSONObject(); json.put("key", property.getKey()); json.put("name", property.getName()); json.put("metadata", propertyMetadataToJson(property.getMetadata())); json.put("visibility", property.getVisibility().toString()); json.put("value", property.getValue().toString()); return json; }
private List<Property> filterProperties(Iterable<Property> properties, boolean includeHidden, Authorizations authorizations) { List<Property> filteredProperties = new ArrayList<>(); for (Property p : properties) { if (canRead(p.getVisibility(), authorizations) && (includeHidden || !p.isHidden(authorizations))) { filteredProperties.add(p); } } return filteredProperties; }
Object propertyValue = property.getValue(); if (propertyValue != null && shouldIgnoreType(propertyValue.getClass())) { return null; jsonBuilder.field(property.getName() + ElasticSearchSearchIndexBase.GEO_PROPERTY_NAME_SUFFIX, propertyValueMap); if (geoPoint.getDescription() != null) { jsonBuilder.field(property.getName(), geoPoint.getDescription()); PropertyDefinition propertyDefinition = indexInfo.getPropertyDefinitions().get(property.getName()); if (propertyDefinition != null && !propertyDefinition.getTextIndexHints().contains(TextIndexHint.FULL_TEXT)) { return null; InputStream in = streamingPropertyValue.getInputStream(); propertyValue = StreamUtils.toString(in); jsonBuilder.field(property.getName(), propertyValue); } else { throw new SecureGraphException("Unhandled StreamingPropertyValue type: " + valueType.getName()); PropertyDefinition propertyDefinition = indexInfo.getPropertyDefinitions().get(property.getName()); if (propertyDefinition == null || propertyDefinition.getTextIndexHints().contains(TextIndexHint.EXACT_MATCH)) { jsonBuilder.field(property.getName() + ElasticSearchSearchIndexBase.EXACT_MATCH_PROPERTY_NAME_SUFFIX, propertyValue); jsonBuilder.field(property.getName(), propertyValue); jsonBuilder.field(property.getName(), propertyValue); jsonBuilder.field(VISIBILITY_FIELD_NAME, property.getVisibility().getVisibilityString());
boolean foundProp1Key1VisB = false; for (Property property : properties) { if (property.getName().equals("prop1")) { if (property.getKey().equals("key2")) { foundProp1Key2 = true; } else if (property.getKey().equals("key1")) { if (property.getVisibility().equals(VISIBILITY_B)) { foundProp1Key1VisB = true; } else { throw new RuntimeException("Unexpected visibility " + property.getVisibility()); throw new RuntimeException("Unexpected property key " + property.getKey()); throw new RuntimeException("Unexpected property name " + property.getName()); foundProp1Key1VisB = false; for (Property property : hiddenProperties) { if (property.getName().equals("prop1")) { if (property.getKey().equals("key2")) { foundProp1Key2 = true; assertFalse("should not be hidden", property.isHidden(AUTHORIZATIONS_A_AND_B)); } else if (property.getKey().equals("key1")) { if (property.getVisibility().equals(VISIBILITY_A)) { foundProp1Key1VisA = true; assertFalse("should not be hidden", property.isHidden(AUTHORIZATIONS_A)); assertTrue("should be hidden", property.isHidden(AUTHORIZATIONS_A_AND_B)); } else if (property.getVisibility().equals(VISIBILITY_B)) { foundProp1Key1VisB = true; assertFalse("should not be hidden", property.isHidden(AUTHORIZATIONS_A_AND_B));
@Override protected Object convert(Property p) { return p.getValue(); } };
@Override public String getName() { return property.getName(); }
public void addPropertyToMutation(Mutation m, String rowKey, Property property) { Text columnQualifier = getPropertyColumnQualifier(property); ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(property.getVisibility()); Object propertyValue = property.getValue(); if (propertyValue instanceof StreamingPropertyValue) { propertyValue = saveStreamingPropertyValue(rowKey, property, (StreamingPropertyValue) propertyValue); } if (propertyValue instanceof DateOnly) { propertyValue = ((DateOnly) propertyValue).getDate(); } Value value = new Value(valueSerializer.objectToValue(propertyValue)); m.put(AccumuloElement.CF_PROPERTY, columnQualifier, columnVisibility, value); addPropertyMetadataToMutation(m, property); }
public void addPropertyToIndex(IndexInfo indexInfo, Property property) throws IOException { String propertyName = property.getName(); if (indexInfo.isPropertyDefined(propertyName)) { return; } Class dataType; Object propertyValue = property.getValue(); if (propertyValue instanceof StreamingPropertyValue) { StreamingPropertyValue streamingPropertyValue = (StreamingPropertyValue) propertyValue; if (!streamingPropertyValue.isSearchIndex()) { return; } dataType = streamingPropertyValue.getValueType(); addPropertyToIndex(indexInfo, propertyName, dataType, true); } else if (propertyValue instanceof String) { dataType = String.class; addPropertyToIndex(indexInfo, propertyName + EXACT_MATCH_PROPERTY_NAME_SUFFIX, dataType, false); addPropertyToIndex(indexInfo, propertyName, dataType, true); } else if (propertyValue instanceof GeoPoint) { addPropertyToIndex(indexInfo, propertyName + GEO_PROPERTY_NAME_SUFFIX, GeoPoint.class, true); addPropertyToIndex(indexInfo, propertyName, String.class, true); } else { checkNotNull(propertyValue, "property value cannot be null for property: " + propertyName); dataType = propertyValue.getClass(); addPropertyToIndex(indexInfo, propertyName, dataType, true); } }
public void update(Property property) { if (property.getHiddenVisibilities() != null) { for (Visibility v : property.getHiddenVisibilities()) { addHiddenVisibility(v); } } setValue(property.getValue()); for (Metadata.Entry m : property.getMetadata().entrySet()) { if (m.getValue() == null) { removeMetadata(m.getKey(), m.getVisibility()); } else { addMetadata(m.getKey(), m.getValue(), m.getVisibility()); } } } }
@Override public Visibility getVisibility() { return property.getVisibility(); }
@Test public void testMetadata() { Vertex v1 = graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_A) .setProperty("prop1", "value1", VISIBILITY_B) .save(AUTHORIZATIONS_A_AND_B); ExistingElementMutation<Vertex> m = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B).prepareMutation(); m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_A), "metadata1", "metadata-value1aa", VISIBILITY_A); m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_A), "metadata1", "metadata-value1ab", VISIBILITY_B); m.setPropertyMetadata(v1.getProperty("prop1", VISIBILITY_B), "metadata1", "metadata-value1bb", VISIBILITY_B); m.save(AUTHORIZATIONS_A_AND_B); v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B); Property prop1A = v1.getProperty("prop1", VISIBILITY_A); assertEquals(2, prop1A.getMetadata().entrySet().size()); assertEquals("metadata-value1aa", prop1A.getMetadata().getValue("metadata1", VISIBILITY_A)); assertEquals("metadata-value1ab", prop1A.getMetadata().getValue("metadata1", VISIBILITY_B)); Property prop1B = v1.getProperty("prop1", VISIBILITY_B); assertEquals(1, prop1B.getMetadata().entrySet().size()); assertEquals("metadata-value1bb", prop1B.getMetadata().getValue("metadata1", VISIBILITY_B)); }
public void addPropertyRemoveToMutation(Mutation m, Property property) { checkNotNull(m, "mutation cannot be null"); checkNotNull(property, "property cannot be null"); Text columnQualifier = getPropertyColumnQualifier(property); ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(property.getVisibility()); m.putDelete(AccumuloElement.CF_PROPERTY, columnQualifier, columnVisibility); for (Metadata.Entry metadataEntry : property.getMetadata().entrySet()) { Text metadataEntryColumnQualifier = getPropertyMetadataColumnQualifier(property, metadataEntry.getKey()); ColumnVisibility metadataEntryVisibility = visibilityToAccumuloVisibility(metadataEntry.getVisibility()); m.putDelete(AccumuloElement.CF_PROPERTY_METADATA, metadataEntryColumnQualifier, metadataEntryVisibility); } }
void alterElementPropertyVisibilities(InMemoryElement element, List<AlterPropertyVisibility> alterPropertyVisibilities, Authorizations authorizations) { for (AlterPropertyVisibility apv : alterPropertyVisibilities) { Property property = element.getProperty(apv.getKey(), apv.getName(), apv.getExistingVisibility()); if (property == null) { throw new SecureGraphException("Could not find property " + apv.getKey() + ":" + apv.getName()); } Object value = property.getValue(); Metadata metadata = property.getMetadata(); element.removeProperty(apv.getKey(), apv.getName(), authorizations); element.addPropertyValue(apv.getKey(), apv.getName(), value, metadata, apv.getVisibility(), authorizations); } }
@Override public String getKey() { return property.getKey(); }
visibilityStrings.add(property.getVisibility().getVisibilityString()); Object propertyValue = property.getValue(); if (propertyValue != null && shouldIgnoreType(propertyValue.getClass())) { continue; propertyValueMap.put("lat", geoPoint.getLatitude()); propertyValueMap.put("lon", geoPoint.getLongitude()); jsonBuilder.field(property.getName() + ElasticSearchSearchIndexBase.GEO_PROPERTY_NAME_SUFFIX, propertyValueMap); if (geoPoint.getDescription() != null) { jsonBuilder.field(property.getName(), geoPoint.getDescription()); PropertyDefinition propertyDefinition = indexInfo.getPropertyDefinitions().get(property.getName()); if (propertyDefinition != null && !propertyDefinition.getTextIndexHints().contains(TextIndexHint.FULL_TEXT)) { continue; PropertyDefinition propertyDefinition = indexInfo.getPropertyDefinitions().get(property.getName()); if (propertyDefinition == null || propertyDefinition.getTextIndexHints().contains(TextIndexHint.EXACT_MATCH)) { jsonBuilder.field(property.getName() + ElasticSearchSearchIndexBase.EXACT_MATCH_PROPERTY_NAME_SUFFIX, propertyValue); jsonBuilder.field(property.getName(), propertyValue); jsonBuilder.field(property.getName(), propertyValue);
boolean foundProp1Key1VisB = false; for (Property property : properties) { if (property.getName().equals("prop1")) { if (property.getKey().equals("key2")) { foundProp1Key2 = true; } else if (property.getKey().equals("key1")) { if (property.getVisibility().equals(VISIBILITY_B)) { foundProp1Key1VisB = true; } else { throw new RuntimeException("Unexpected visibility " + property.getVisibility()); throw new RuntimeException("Unexpected property key " + property.getKey()); throw new RuntimeException("Unexpected property name " + property.getName()); foundProp1Key1VisB = false; for (Property property : hiddenProperties) { if (property.getName().equals("prop1")) { if (property.getKey().equals("key2")) { foundProp1Key2 = true; assertFalse("should not be hidden", property.isHidden(AUTHORIZATIONS_A_AND_B)); } else if (property.getKey().equals("key1")) { if (property.getVisibility().equals(VISIBILITY_A)) { foundProp1Key1VisA = true; assertFalse("should not be hidden", property.isHidden(AUTHORIZATIONS_A)); assertTrue("should be hidden", property.isHidden(AUTHORIZATIONS_A_AND_B)); } else if (property.getVisibility().equals(VISIBILITY_B)) { foundProp1Key1VisB = true; assertFalse("should not be hidden", property.isHidden(AUTHORIZATIONS_A_AND_B));
@Override protected Object convert(Property p) { return p.getValue(); } };