@Override public boolean completeEquals(final Object obj) { return Component.class.isInstance(obj) && super.completeEquals(obj) && Objects.equal(((Component) obj).getParameterMappings(), getParameterMappings()) && DMPPersistenceUtil.getFunctionUtils().completeEquals(((Component) obj).getFunction(), getFunction()) && Objects.equal(((Component) obj).getInputComponents(), getInputComponents()) && Objects.equal(((Component) obj).getOutputComponents(), getOutputComponents()); }
if (component.getOutputComponents() == null || component.getOutputComponents().isEmpty()) { if (component.getOutputComponents() == null || component.getOutputComponents().isEmpty()) {
/** * sort components re. their natural order (begin from the end, i.e., component without output components) * * @param components original components set * @return */ private static javaslang.collection.List<Component> sortComponents(final Set<Component> components) { final Optional<Component> optionalLastComponent = components.stream() .filter(component -> { final Set<Component> outputComponents = component.getOutputComponents(); return outputComponents == null || outputComponents.isEmpty(); }) .findFirst(); if (!optionalLastComponent.isPresent()) { return javaslang.collection.List.ofAll(components); } final Component lastComponent = optionalLastComponent.get(); final javaslang.collection.List<Component> lastComponentList = javaslang.collection.List.of(lastComponent); final javaslang.collection.Map<String, Component> componentMap = javaslang.collection.HashSet.ofAll(components) .toMap(component -> Tuple.of(component.getUuid(), component)); final javaslang.collection.List<Component> emptyComponentList = javaslang.collection.List.empty(); return addComponents(lastComponentList, componentMap, emptyComponentList); }
/** * note: result will be cache (temporarily - for re-utilisation in a test) * * @return * @throws Exception */ @Override public Transformation createAndPersistDefaultCompleteObject() throws Exception { final String transformationName = "my transformation"; if (!cache.containsKey(transformationName)) { final String transformationDescription = "transformation which just makes use of one function"; final String transformationParameter = "transformationInputString"; final Component component = componentServiceTestUtils.createAndPersistDefaultCompleteObject(); final Set<Component> components = Sets.newLinkedHashSet(); components.add(component.getInputComponents().iterator().next()); components.add(component); components.add(component.getOutputComponents().iterator().next()); final LinkedList<String> parameters = Lists.newLinkedList(); parameters.add(transformationParameter); final Transformation transformation = createTransformation(transformationName, transformationDescription, components, parameters); cache.put(transformationName, transformation); } return cache.get(transformationName); }
private static void testTransformation(final Transformation transformation) { MatcherAssert.assertThat(transformation.getUuid(), Matchers.equalTo("42")); MatcherAssert.assertThat(transformation.getFunctionType(), Matchers.equalTo(FunctionType.Transformation)); MatcherAssert.assertThat(transformation.getName(), Matchers.equalTo("transformation")); MatcherAssert.assertThat(transformation.getDescription(), Matchers.equalTo("transformation")); MatcherAssert.assertThat(transformation.getFunctionDescription(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(transformation.getParameters(), Matchers.hasSize(1)); MatcherAssert.assertThat(transformation.getParameters(), Matchers.hasItems("transformationInputString")); MatcherAssert.assertThat(transformation.getComponents(), Matchers.hasSize(3)); final Component c1 = CustomTransformationDeserializerTest.checkComponent(transformation, "1", "compose", "Add pre- or postfix to a string.", Lists.newArrayList("prefix", "postfix"), Tuple.tuple("inputString", "variable_name")); final Component c2 = CustomTransformationDeserializerTest.checkComponent(transformation, "2", "case", "Upper/lower-case transformation.", Lists.newArrayList("to", "language")); final Component c3 = CustomTransformationDeserializerTest .checkComponent(transformation, "3", "count", "Returns the an increasing count for each received literal.", Collections.<String>emptyList(), Tuple.tuple("inputString", "dataset")); // *C1* --> C2 MatcherAssert.assertThat(c1.getInputComponents(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(c1.getOutputComponents(), Matchers.hasSize(1)); MatcherAssert.assertThat(Iterators.getOnlyElement(c1.getOutputComponents().iterator()), Matchers.is(Matchers.sameInstance(c2))); // C1 --> *C2* MatcherAssert.assertThat(c2.getInputComponents(), Matchers.hasSize(1)); MatcherAssert.assertThat(c2.getOutputComponents(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(Iterators.getOnlyElement(c2.getInputComponents().iterator()), Matchers.is(Matchers.sameInstance(c1))); MatcherAssert.assertThat(c3.getInputComponents(), Matchers.is(Matchers.nullValue())); MatcherAssert.assertThat(c3.getOutputComponents(), Matchers.is(Matchers.nullValue())); }
/** * {@inheritDoc} */ @Override public void updateObjectInternal(final Component object, final Component updateObject) throws DMPPersistenceException { super.updateObjectInternal(object, updateObject); final Function function = object.getFunction(); final Set<Component> inputComponents = object.getInputComponents(); final Set<Component> outputComponents = object.getOutputComponents(); final Map<String, String> parameterMappings = object.getParameterMappings(); // final Transformation transformation = object.getTransformation(); updateObject.setFunction(function); updateObject.setInputComponents(inputComponents); updateObject.setOutputComponents(outputComponents); updateObject.setParameterMappings(parameterMappings); // updateObject.setTransformation(transformation); }
/** * Create a new {@code Component} as a copy from a existing component with a specific id. <br> * <b>Use with care!</b> * <p> * This factory is to be used by {@link org.dswarm.persistence.model.job.utils.TransformationDeserializer} to avoid reflection * based access to a private/protected field, since the Json deserializer needs a way to set the id that was provided by the * JSON. * </p> * <p> * The id is otherwise assigned by the database/Hibernate layer. You should never need this outside of * {@code TransformationDeserializer}. * </p> * * @param component the base component that will be copied * @param uuid the target component's id value * @return a new component with the given id and all other attributes copied from the provided component. */ public static Component withId(final Component component, final String uuid) { final Component newComponent = new Component(uuid); newComponent.setFunction(component.getFunction()); newComponent.setInputComponents(component.getInputComponents()); newComponent.setOutputComponents(component.getOutputComponents()); newComponent.setParameterMappings(component.getParameterMappings()); newComponent.setDescription(component.getDescription()); newComponent.setName(component.getName()); return newComponent; } }
Assert.assertEquals("the component input component '" + component1.getUuid() + "' are not equal", component1, component.getInputComponents() .iterator().next()); Assert.assertNotNull("the component output components set shouldn't be null", component.getOutputComponents()); Assert.assertEquals("the component output components set are not equal", 1, component.getOutputComponents().size()); Assert.assertTrue("the component output components set doesn't contain component '" + component2.getUuid() + "'", component .getOutputComponents().contains(component2)); Assert.assertEquals("the component output component '" + component2.getUuid() + "' are not equal", component2, component.getOutputComponents() .iterator().next());
Assert.assertEquals("the component input component '" + component1.getUuid() + "' are not equal", component1, mainComponent .getInputComponents().iterator().next()); Assert.assertNotNull("the component output components set shouldn't be null", mainComponent.getOutputComponents()); Assert.assertEquals("the component output components set are not equal", 1, mainComponent.getOutputComponents().size()); Assert.assertTrue("the component output components set doesn't contain component '" + component2.getUuid() + "'", mainComponent .getOutputComponents().contains(component2)); Assert.assertEquals("the component output component '" + component2.getUuid() + "' are not equal", component2, mainComponent .getOutputComponents().iterator().next());
if (expectedComponent.getOutputComponents() == null || expectedComponent.getOutputComponents().isEmpty()) { final boolean actualComponentHasNoOutputComponents = (actualComponent.getOutputComponents() == null || actualComponent .getOutputComponents().isEmpty()); Assert.assertTrue("actual component should not have any output components", actualComponentHasNoOutputComponents); prepareAndCompareComponents(actualComponent.getUuid(), expectedComponent.getOutputComponents(), actualComponent.getOutputComponents(), "output");
final Set<Component> outputComponents = objectWithUpdates.getOutputComponents(); Set<Component> newOutputComponents;