/** * {@inheritDoc}<br/> * Clears the relationship to the input attribute paths, output attribute path, input filter and output filter. */ @Override protected void prepareObjectForRemoval(final Mapping object) { // should clear the relationship to the input attribute paths, output attribute path + transformation function object.setInputAttributePaths(null); object.setOutputAttributePath(null); final Component transformation = object.getTransformation(); if (transformation != null) { transformation.setFunction(null); } }
/** * Sets the machine processable function description * * @param functionDescriptionArg a new machine processable function description */ public void setFunctionDescription(final ObjectNode functionDescriptionArg) { functionDescription = functionDescriptionArg; refreshFunctionDescriptionString(); }
/** * convert collect function to concat function to allow concatenating of field that occur multiple times in a record * * @param multipleInputComponent */ private static void convertCollectFunction(final Component multipleInputComponent, final String flushWithEntity) { multipleInputComponent.addParameterMapping(MF_FLUSH_WITH_ATTRIBUTE_IDENTIFIER, flushWithEntity); multipleInputComponent.addParameterMapping(MF_COLLECTOR_RESET_ATTRIBUTE_IDENTIFIER, BOOLEAN_VALUE_TRUE); }
@Test public void testSqlDbRequestTask() throws Exception { final Task task = getTask("sqldbrequest.task.json"); final Job job = task.getJob(); final Set<Mapping> mappings = job.getMappings(); final Mapping mapping = mappings.iterator().next(); final Component mappingTransformationComponent = mapping.getTransformation(); final Transformation mappingTransformationComponentFunction = (Transformation) mappingTransformationComponent.getFunction(); final Set<Component> mappingTransformationComponentFunctionComponents = mappingTransformationComponentFunction.getComponents(); final Component sqlMapLookup = mappingTransformationComponentFunctionComponents.iterator().next(); final Map<String, String> sqlMapLookupParameterMappings = sqlMapLookup.getParameterMappings(); final String user = readManuallyFromTypeSafeConfig("dswarm.db.metadata.username"); final String pass = readManuallyFromTypeSafeConfig("dswarm.db.metadata.password"); final String db = readManuallyFromTypeSafeConfig("dswarm.db.metadata.schema"); setSqlMapParameterMappings(sqlMapLookupParameterMappings, user, pass, db); testXMLTaskWithTuples("sqldbrequest.task.result.json", "sqldbrequest.mabxml.tuples.json", task); }
/** * {@inheritDoc}<br/> * Updates the name, transformation (component), input attribute paths and output attribute path of the mapping. */ @Override protected Mapping prepareObjectForUpdate(final Mapping objectWithUpdates, final Mapping object) { super.prepareObjectForUpdate(objectWithUpdates, object); object.setTransformation(objectWithUpdates.getTransformation()); object.setInputAttributePaths(objectWithUpdates.getInputAttributePaths()); object.setOutputAttributePath(objectWithUpdates.getOutputAttributePath()); return object; }
private static Function checkFunction(final Component component, final String uuid, final String name, final String description, final String... parameters) { final Function function = component.getFunction(); MatcherAssert.assertThat(function, Matchers.is(Matchers.notNullValue())); MatcherAssert.assertThat(function.getUuid(), Matchers.equalTo(uuid)); MatcherAssert.assertThat(function.getName(), Matchers.equalTo(name)); MatcherAssert.assertThat(function.getDescription(), Matchers.equalTo(description)); MatcherAssert.assertThat(function.getFunctionType(), Matchers.equalTo(FunctionType.Function)); MatcherAssert.assertThat(function.getParameters(), Matchers.hasItems(parameters)); return function; } }
/** * {@inheritDoc}<br/> * Clears the relationship to the input data model, output data model, mappings and functions. */ @Override protected void prepareObjectForRemoval(final Project object) { // should clear the relationship to the input data model, output data model, mappings and functions object.setInputDataModel(null); object.setOutputDataModel(null); object.setMappings(null); object.setSkipFilter(null); object.setFunctions(null); }
private void replaceFunctionsInComponent(final Component component) throws DMPPersistenceException { if (component == null) { return; } final Function existingComponentFunction = component.getFunction(); final FunctionType componentFunctionFunctionType = existingComponentFunction.getFunctionType(); switch (componentFunctionFunctionType) { case Function: final Function persistentFunction = replaceFunction(existingComponentFunction); component.setFunction(persistentFunction); break; case Transformation: replaceFunctionsInTransformation((Transformation) existingComponentFunction); break; } }
private static String getComponentFunctionName(final Component component) { final String componentFunctionName = component.getFunction().getName(); if (METAMORPH_FUNCTION_SQLMAP.equals(componentFunctionName)) { return METAMORPH_FUNCTION_LOOKUP; } return componentFunctionName; }
/** * {@inheritDoc} */ @Override public void updateObjectInternal(final Transformation object, final Transformation updateObject) throws DMPPersistenceException { super.updateObjectInternal(object, updateObject); final Set<Component> components = object.getComponents(); updateObject.setComponents(components); }
/** * {@inheritDoc}<br/> * Clears the relationship to the function, input components and output components. */ @Override protected void prepareObjectForRemoval(final Component object) { // release connections to other objects object.setFunction(null); object.setInputComponents(null); object.setOutputComponents(null); }
@Override public boolean completeEquals(final Object obj) { return Transformation.class.isInstance(obj) && super.completeEquals(obj) && DMPPersistenceUtil.getComponentUtils().completeEquals(((Transformation) obj).getComponents(), getComponents()); }
private void replaceFunctionsInTransformation(final Transformation transformation) throws DMPPersistenceException { if (transformation == null) { return; } final Set<Component> transformationComponents = transformation.getComponents(); if (transformationComponents == null) { return; } for (final Component transformationComponent : transformationComponents) { replaceFunctionsInComponent(transformationComponent); } }
/** * Set the function of a component. Delegates to annotation/databind based parsing of a * {@link org.dswarm.persistence.model.job.Function} * * @param jp the current json parser * @param component the target {@code Component} * @throws IOException */ private static void setFunction(final JsonParser jp, final Component component) throws IOException { final Function function = jp.readValueAs(Function.class); component.setFunction(function); }
/** * Removes an existing output component from the collection of output components of this component.<br> * Created by: tgaengler * * @param outputComponent an existing output component that should be removed */ public void removeOutputComponent(final Component outputComponent) { if (outputComponents != null && outputComponent != null && outputComponents.contains(outputComponent)) { outputComponents.remove(outputComponent); outputComponent.removeInputComponent(this); } }
/** * Removes an existing input component from the collection of input components of this component.<br> * Created by: tgaengler * * @param inputComponent an existing input component that should be removed */ public void removeInputComponent(final Component inputComponent) { if (inputComponents != null && inputComponent != null && inputComponents.contains(inputComponent)) { inputComponents.remove(inputComponent); inputComponent.removeOutputComponent(this); } }
private Component createNewComponentWithId(final Component currentComponent, final String componentId) throws JsonMappingException { return Component.withId(currentComponent, componentId); }
/** * Gets the parameters of the function. * * @return the parameters of the function */ @XmlElement(name = "parameters") public LinkedList<String> getParameters() { initParameters(false); return parameters; }
/** * Set the components for a transformation. * * @param transformation the target {@code Transformation} * @param components the target components, a map of (id -> {@code Component}) */ private static void addComponents(final Transformation transformation, final Map<String, Component> components) { for (final Component component : components.values()) { transformation.addComponent(component); } }
/** * {@inheritDoc}<br/> * Updates the name, description, parameters, machine processable function description and components of the transformation. */ @Override protected Transformation prepareObjectForUpdate(final Transformation objectWithUpdates, final Transformation object) { super.prepareObjectForUpdate(objectWithUpdates, object); object.setComponents(objectWithUpdates.getComponents()); return object; }