@Override public T apply(T current, T transformed) { for (Map.Entry<String, String> mapping : keyMappings.entrySet()) { if (current.getPropertyValue(mapping.getKey()) != null) { current.setProperty(mapping.getValue(), current.getPropertyValue(mapping.getKey())); current.removeProperty(mapping.getKey()); } } return current; } }
@Override public GradoopId getKey(Tuple2<K, GradoopId> value) throws Exception { return value.f0.getId(); } }
@Override public Put writeProperties(final Put put, final EPGMElement entity) { if (entity.getProperties() != null && entity.getPropertyCount() > 0) { for (Property property : entity.getProperties()) { writeProperty(put, property); } } return put; }
@Override public EL apply(EL current, EL transformed) { transformed.setLabel(current.getLabel()); transformed.setProperties(current.getProperties()); if ((label == null) || label.equals(current.getLabel())) { if (current.hasProperty(propertyKey)) { transformed.setProperty( propertyKey + PROPERTY_VERSION_SEPARATOR + getNextVersionNumber(current), current.getPropertyValue(propertyKey)); transformed.setProperty( propertyKey, transformationFunction.execute(current.getPropertyValue(propertyKey))); transformed.setProperty( newPropertyKey, transformationFunction.execute(current.getPropertyValue(propertyKey)));
/** * Adds label and properties of an EPGM element to id-label and id-properties maps. * * @param element EPGM element * @param labels id-label map * @param properties id-properties map */ private static void addLabelsAndProperties( EPGMElement element, Map<GradoopId, String> labels, Map<GradoopId, Properties> properties ) { labels.put(element.getId(), element.getLabel()); Properties propertyList = element.getProperties(); if (propertyList != null && !propertyList.isEmpty()) { properties.put(element.getId(), propertyList); } }
assertNotNull("second element was null", element2); assertEquals("id mismatch", element1.getId(), element2.getId()); assertEquals("label mismatch", element1.getLabel(), element2.getLabel()); if (element1.getPropertyCount() == 0) { assertEquals("property count mismatch", element1.getPropertyCount(), element2.getPropertyCount()); } else { List<String> keys1 = Lists.newArrayList(element1.getPropertyKeys()); Collections.sort(keys1); List<String> keys2 = Lists.newArrayList(element2.getPropertyKeys()); Collections.sort(keys2); assertEquals("property key mismatch", key1, key2); assertEquals("property value mismatch", element1.getPropertyValue(key1), element2.getPropertyValue(key2));
@Override public E apply(E current, E transformed) { PropertyValue timePropertyValue = current.getPropertyValue(propertyKey); if (timePropertyValue == null) { return current; } LocalDateTime timeOfCall = LocalDateTime.ofEpochSecond( (long) timePropertyValue.getInt(), 0, OffsetDateTime.now().getOffset()); transformed.setLabel(current.getLabel()); transformed.setProperty("year", timeOfCall.getYear()); transformed.setProperty("month", timeOfCall.getMonth().getValue()); transformed.setProperty("day", timeOfCall.getDayOfMonth()); transformed.setProperty("hour", timeOfCall.getHour()); transformed.setProperty("minute", timeOfCall.getMinute()); return transformed; } }
if (element.hasProperty(groupPropertyKey)) { groupingValues.add(element.getPropertyValue(groupPropertyKey)); } else { groupingValues.add(PropertyValue.NULL_VALUE); groupItem.setGroupLabel(element.getLabel()); } else { groupItem.setGroupLabel(labelGroup.getGroupLabel());
assertNotNull(epgmElement.getProperties()); assertEquals(PROPERTY_MAP.size(), epgmElement.getPropertyCount()); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_0)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_1)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_2)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_3)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_4)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_5)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_6)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_7)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_8)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_9)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_a)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_b)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_c)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_d)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_e)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_f)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_g)); assertTrue(epgmElement.hasProperty(GradoopTestUtils.KEY_h)); assertTrue(epgmElement.getPropertyValue(GradoopTestUtils.KEY_0).isBoolean()); assertTrue(epgmElement.getPropertyValue(GradoopTestUtils.KEY_1).isInt()); assertTrue(epgmElement.getPropertyValue(GradoopTestUtils.KEY_2).isLong()); assertTrue(epgmElement.getPropertyValue(GradoopTestUtils.KEY_3).isFloat()); assertTrue(epgmElement.getPropertyValue(GradoopTestUtils.KEY_4).isDouble()); assertTrue(epgmElement.getPropertyValue(GradoopTestUtils.KEY_5).isString());
@Override public boolean filter(E e) throws Exception { if (e.hasProperty(key)) { if (value != null) { if (e.getPropertyValue(key).equals(value)) { return true; } } else { return true; } } return false; } }
@Override public boolean test(T t) { return t.getPropertyValue(getKey()) != null && t.getPropertyValue(getKey()).equals(getValue()); }
@Override public org.gradoop.common.model.impl.properties.Properties getKey(L l) throws Exception { return l.getProperties(); } }
/** * Returns the next unused version number. * * @param element element whose property shall be transformed up * @return next unused version number */ protected int getNextVersionNumber(EL element) { int i = 1; while (element.hasProperty(propertyKey + PROPERTY_VERSION_SEPARATOR + i)) { i++; } return i; } }
/** * Adds label and properties of an EPGM element to id-label and id-properties maps. * * @param element EPGM element * @param labels id-label map * @param properties id-properties map */ private static void addLabelsAndProperties( EPGMElement element, Map<GradoopId, String> labels, Map<GradoopId, Properties> properties ) { labels.put(element.getId(), element.getLabel()); Properties propertyList = element.getProperties(); if (propertyList != null && !propertyList.isEmpty()) { properties.put(element.getId(), propertyList); } }
if (element.hasProperty(groupPropertyKey)) { groupingValues.add(element.getPropertyValue(groupPropertyKey)); } else { groupingValues.add(PropertyValue.NULL_VALUE); groupItem.setGroupLabel(element.getLabel()); } else { groupItem.setGroupLabel(labelGroup.getGroupLabel());
@Override public boolean filter(E e) throws Exception { if (e.hasProperty(key)) { if (value != null) { if (e.getPropertyValue(key).equals(value)) { return true; } } else { return true; } } return false; } }
@Override public boolean test(T t) { PropertyValue value = t.getPropertyValue(getKey()); return value != null && value.isString() && getReg().matcher(value.getString()).matches(); }