public void copyProperties(final Properties properties) { if (null != properties) { for (final Entry<String, Object> entry : properties.entrySet()) { putProperty(entry.getKey(), entry.getValue()); } } }
@Override public void put(final String reference, final Object value) { if (ELEMENT.equals(reference)) { throw new IllegalArgumentException("You are not allowed to set an entire Element on this ElementTuple"); } if (PROPERTIES.equals(reference)) { element.copyProperties(((Properties) value)); } final IdentifierType idType = IdentifierType.fromName(reference); if (null == idType) { element.putProperty(reference, value); } else { element.putIdentifier(idType, value); } }
@Test public void shouldRemoveProperty() { // Given final Element element1 = newElement("group"); element1.putProperty("property1", "propertyValue1"); element1.putProperty("property2", "propertyValue2"); // When element1.removeProperty("property1"); // Then assertEquals(1, element1.getProperties().size()); assertEquals(null, element1.getProperty("property1")); assertEquals("propertyValue2", element1.getProperty("property2")); }
public void copyProperties(final Properties properties) { if (null != properties) { for (final Entry<String, Object> entry : properties.entrySet()) { putProperty(entry.getKey(), entry.getValue()); } } }
@Override public void put(final String reference, final Object value) { if (ELEMENT.equals(reference)) { throw new IllegalArgumentException("You are not allowed to set an entire Element on this ElementTuple"); } if (PROPERTIES.equals(reference)) { element.copyProperties(((Properties) value)); } final IdentifierType idType = IdentifierType.fromName(reference); if (null == idType) { element.putProperty(reference, value); } else { element.putIdentifier(idType, value); } }
((Entity) e).setVertex(gafferObject); } else { e.putProperty(column, gafferObject); isDir = (boolean) gafferObject; } else { e.putProperty(column, gafferObject);
private Boolean isVisible(final Element e) throws VisibilityParseException { if (e.getProperty(visibility) != null) { final VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(auths); final ElementVisibility elementVisibility = new ElementVisibility((String) e.getProperty(visibility)); return visibilityEvaluator.evaluate(elementVisibility); } else { e.putProperty(visibility, new String()); return true; } } }
/** * Clone an {@link Element}, based on a target {@link Schema}. * * @param element the element to clone * @param schema the schema * @return the cloned element */ public Element cloneElement(final Element element, final Schema schema) { try { final Element clone = element.emptyClone(); final SchemaElementDefinition sed = schema.getElement(clone.getGroup()); for (final String propertyName : element.getProperties().keySet()) { final Object property = element.getProperty(propertyName); if (null == sed.getPropertyTypeDef(propertyName) || null == sed.getPropertyTypeDef(propertyName).getSerialiser()) { // This can happen if transient properties are derived - they will not have serialisers. LOGGER.warn("Can't find Serialisation for {}, returning uncloned property", propertyName); clone.putProperty(propertyName, property); } else if (null != property) { final Serialiser serialiser = sed.getPropertyTypeDef(propertyName).getSerialiser(); clone.putProperty(propertyName, serialiser.deserialise(serialiser.serialise(property))); } else { clone.putProperty(propertyName, null); } } return clone; } catch (final SerialisationException e) { throw new RuntimeException("SerialisationException converting elements", e); } } }
private Element addNonAggElement(final Element element, final Schema schema, final MapImpl mapImpl) { final Element elementClone = element.emptyClone(); // Copy properties that exist in the schema final SchemaElementDefinition elementDef = schema.getElement(element.getGroup()); for (final String property : elementDef.getProperties()) { elementClone.putProperty(property, element.getProperty(property)); } mapImpl.addNonAggElement(elementClone); return elementClone; }
@Override public Element _apply(final Row row) { final Element element; final String group = row.getAs(SchemaToStructTypeConverter.GROUP); final Object source = ArrayUtils.contains(row.schema().fieldNames(), SchemaToStructTypeConverter.SRC_COL_NAME) ? row.getAs(SchemaToStructTypeConverter.SRC_COL_NAME) : null; if (null != source) { final Object destination = row.getAs(SchemaToStructTypeConverter.DST_COL_NAME); final boolean directed = row.getAs(SchemaToStructTypeConverter.DIRECTED_COL_NAME); final MatchedVertex matchedVertex; if (ArrayUtils.contains(row.schema().fieldNames(), SchemaToStructTypeConverter.MATCHED_VERTEX_COL_NAME)) { final String matchedVertexStr = row.getAs(SchemaToStructTypeConverter.MATCHED_VERTEX_COL_NAME); matchedVertex = null != matchedVertexStr ? MatchedVertex.valueOf(matchedVertexStr) : null; } else { matchedVertex = null; } element = new Edge(group, source, destination, directed, matchedVertex, null); } else { final Object vertex = ArrayUtils.contains(row.schema().fieldNames(), SchemaToStructTypeConverter.VERTEX_COL_NAME) ? row.getAs(SchemaToStructTypeConverter.VERTEX_COL_NAME) : row.getAs(SchemaToStructTypeConverter.ID); element = new Entity(group, vertex); } getPropertyNames(row).forEach(n -> { element.putProperty(n, row.getAs(n)); }); return element; }
private Element addAggElement(final Element element, final Schema schema, final MapImpl mapImpl) { final String group = element.getGroup(); final Element elementWithGroupByProperties = element.emptyClone(); final GroupedProperties properties = new GroupedProperties(element.getGroup()); for (final String propertyName : mapImpl.getGroupByProperties(group)) { elementWithGroupByProperties.putProperty(propertyName, element.getProperty(propertyName)); } for (final String propertyName : mapImpl.getNonGroupByProperties(group)) { properties.put(propertyName, element.getProperty(propertyName)); } mapImpl.addAggElement(elementWithGroupByProperties, properties); return elementWithGroupByProperties; }