use of io.atlasmap.v2.Equals in project syndesis-qe by syndesisio.
the class UiComplexSteps method processMapperSteps.
private void processMapperSteps() {
List<StepDefinition> mappers = steps.getStepDefinitions().stream().filter(s -> s.getStep().getStepKind().equals(StepKind.mapper)).collect(Collectors.toList());
if (mappers.isEmpty()) {
log.debug("There are no mappers in this integration, proceeding...");
} else {
// mapping can be done on steps that preceed mapper step and the single step, which follows the mapper step.
log.info("Found mapper step, creating new atlas mapping.");
for (int i = 0; i < mappers.size(); i++) {
List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mappers.get(i))).stream().filter(s -> s.getConnectorDescriptor().isPresent()).collect(Collectors.toList());
StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mappers.get(i)) + 1);
if (mappers.get(i).getStep().getConfiguredProperties().containsKey("atlasmapping")) {
// TODO(tplevko): think of some way to substitute placeholders for the step ID's
reflectStepIdsInAtlasMapping(mappers.get(i), precedingSteps, followingStep);
} else {
// TODO(tplevko): fix for more than one preceding step.
mappers.get(i).setStep(atlasGenerator.getAtlasMappingStep(mappers.get(i), precedingSteps, followingStep));
}
}
}
}
use of io.atlasmap.v2.Equals in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method internalProcessActions.
protected Field internalProcessActions(Actions actions, Object sourceObject, FieldType targetType) throws AtlasException {
Field processedField = new SimpleField();
processedField.setValue(sourceObject);
processedField.setFieldType(targetType);
if (FieldType.COMPLEX.equals(targetType)) {
return processedField;
}
Object tmpSourceObject = sourceObject;
FieldType sourceType = (sourceObject != null ? getConversionService().fieldTypeFromClass(sourceObject.getClass()) : FieldType.NONE);
if (actions == null || actions.getActions() == null || actions.getActions().isEmpty()) {
if (sourceObject == null) {
return processedField;
}
processedField.setValue(getConversionService().convertType(sourceObject, sourceType, targetType));
processedField.setFieldType(targetType);
return processedField;
}
FieldType currentType = sourceType;
for (Action action : actions.getActions()) {
ActionDetail detail = findActionDetail(action.getDisplayName(), currentType);
if (!detail.getSourceType().equals(currentType) && !FieldType.ANY.equals(detail.getSourceType())) {
tmpSourceObject = getConversionService().convertType(sourceObject, currentType, detail.getSourceType());
}
processedField.setValue(processAction(action, detail, tmpSourceObject));
processedField.setFieldType(detail.getTargetType());
currentType = detail.getTargetType();
}
return processedField;
}
use of io.atlasmap.v2.Equals in project atlasmap by atlasmap.
the class StringLengthValidatorTest method testValidateInvalid.
@Test
public void testValidateInvalid() {
String pass = "";
validator.validate(pass, validations, "testValidateInvalid");
assertTrue(validationHelper.hasErrors());
assertEquals(new Integer(1), new Integer(validationHelper.getAllValidations().size()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("testValidateInvalid", validation.getId());
assertTrue("Must be of this length".equals(validation.getMessage()));
}
use of io.atlasmap.v2.Equals in project atlasmap by atlasmap.
the class XmlFieldReader method read.
public void read(AtlasInternalSession session) throws AtlasException {
if (document == null) {
throw new AtlasException(new IllegalArgumentException("'document' cannot be null"));
}
Field field = session.head().getSourceField();
if (field == null) {
throw new AtlasException(new IllegalArgumentException("Argument 'field' cannot be null"));
}
seedDocumentNamespaces(document);
XmlField xmlField = XmlField.class.cast(field);
if (LOG.isDebugEnabled()) {
LOG.debug("Reading source value for field: " + xmlField.getPath());
}
if (document == null) {
throw new AtlasException(new IllegalArgumentException("Argument 'document' cannot be null"));
}
if (xmlField == null) {
throw new AtlasException(new IllegalArgumentException("Argument 'xmlField' cannot be null"));
}
Element parentNode = document.getDocumentElement();
for (SegmentContext sc : new XmlPath(xmlField.getPath()).getSegmentContexts(false)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Now processing segment: " + sc.getSegment());
LOG.debug("Parent element is currently: " + XmlIOHelper.writeDocumentToString(true, parentNode));
}
if (sc.getPrev() == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping root segment: " + sc);
}
// "/XOA/contact<>/firstName", skip.
continue;
}
if (!XmlPath.isAttributeSegment(sc.getSegment())) {
String childrenElementName = XmlPath.cleanPathSegment(sc.getSegment());
String namespaceAlias = XmlPath.getNamespace(sc.getSegment());
if (namespaceAlias != null && !"".equals(namespaceAlias)) {
childrenElementName = namespaceAlias + ":" + childrenElementName;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Looking for children elements with name: " + childrenElementName);
}
List<Element> children = XmlIOHelper.getChildrenWithName(childrenElementName, parentNode);
if (children == null || children.isEmpty()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping source value set, couldn't find children with name '" + childrenElementName + "', for segment: " + sc);
}
return;
}
parentNode = children.get(0);
if (XmlPath.isCollectionSegment(sc.getSegment())) {
int index = XmlPath.indexOfSegment(sc.getSegment());
if (index >= children.size()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping source value set, children list can't fit index " + index + ", children list size: " + children.size());
}
return;
}
parentNode = children.get(index);
}
}
if (sc.getNext() == null) {
// last segment.
String value = parentNode.getTextContent();
if (XmlPath.isAttributeSegment(sc.getSegment())) {
String attributeName = XmlPath.getAttribute(sc.getSegment());
value = parentNode.getAttribute(attributeName);
}
if (value == null) {
return;
}
if (xmlField.getFieldType() == null) {
xmlField.setValue(value);
xmlField.setFieldType(FieldType.STRING);
} else {
Object convertedValue;
try {
convertedValue = conversionService.convertType(value, xmlField.getFormat(), xmlField.getFieldType(), null);
xmlField.setValue(convertedValue);
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, xmlField.getDocId(), String.format("Failed to convert field value '%s' into type '%s'", value, xmlField.getFieldType()), xmlField.getPath(), AuditStatus.ERROR, value);
}
}
}
}
}
use of io.atlasmap.v2.Equals in project atlasmap by atlasmap.
the class JsonModule method processTargetFieldMapping.
@Override
public void processTargetFieldMapping(AtlasInternalSession session) throws AtlasException {
Field sourceField = session.head().getSourceField();
Field targetField = session.head().getTargetField();
// Attempt to Auto-detect field type based on input value
if (targetField.getFieldType() == null && sourceField.getValue() != null) {
targetField.setFieldType(getConversionService().fieldTypeFromClass(sourceField.getValue().getClass()));
}
Object targetValue = null;
// Do auto-conversion
if (sourceField.getFieldType() != null && sourceField.getFieldType().equals(targetField.getFieldType())) {
targetValue = sourceField.getValue();
} else if (sourceField.getValue() != null) {
try {
targetValue = getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), targetField.getFieldType(), targetField.getFormat());
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, targetField.getDocId(), String.format("Unable to auto-convert for sT=%s tT=%s tF=%s msg=%s", sourceField.getFieldType(), targetField.getFieldType(), targetField.getPath(), e.getMessage()), targetField.getPath(), AuditStatus.ERROR, null);
return;
}
}
targetField.setValue(targetValue);
LookupTable lookupTable = session.head().getLookupTable();
if (lookupTable != null) {
processLookupField(session, lookupTable, targetField.getValue(), targetField);
}
if (isAutomaticallyProcessOutputFieldActions() && targetField.getActions() != null && targetField.getActions().getActions() != null) {
getFieldActionService().processActions(targetField.getActions(), targetField);
}
JsonFieldWriter writer = session.getFieldWriter(getDocId(), JsonFieldWriter.class);
writer.write(session);
}
Aggregations