use of com.google.firestore.admin.v1.Field in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method generateSeparateMapping.
private Mapping generateSeparateMapping(DataMapperStepDefinition mappingDef, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
StepDefinition fromStep = precedingSteps.get(mappingDef.getFromStep() - 1);
Mapping generatedMapping = new Mapping();
generatedMapping.setId(UUID.randomUUID().toString());
generatedMapping.setMappingType(MappingType.SEPARATE);
generatedMapping.setDelimiter(mappingDef.getStrategy().name());
List<Field> out = new ArrayList<>();
for (int i = 0; i < mappingDef.getOutputFields().size(); i++) {
String def = mappingDef.getOutputFields().get(i);
Field outField = followingStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(def)).findFirst().get();
outField.setIndex(i);
out.add(outField);
}
Field in = fromStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getInputFields().get(0))).findFirst().get();
out.forEach(f -> f.setDocId(followingStep.getStep().getId().get()));
in.setDocId(fromStep.getStep().getId().get());
generatedMapping.getOutputField().addAll(out);
generatedMapping.getInputField().add(in);
return generatedMapping;
}
use of com.google.firestore.admin.v1.Field in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method generateMapMapping.
private Mapping generateMapMapping(DataMapperStepDefinition mappingDef, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
StepDefinition fromStep = precedingSteps.get(mappingDef.getFromStep() - 1);
Mapping generatedMapping = new Mapping();
generatedMapping.setId(UUID.randomUUID().toString());
generatedMapping.setMappingType(MappingType.MAP);
Field in = fromStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getInputFields().get(0))).findFirst().get();
Field out = followingStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getOutputFields().get(0))).findFirst().get();
in.setDocId(fromStep.getStep().getId().get());
out.setDocId(followingStep.getStep().getId().get());
generatedMapping.getInputField().add(in);
generatedMapping.getOutputField().add(out);
return generatedMapping;
}
use of com.google.firestore.admin.v1.Field in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method processDataShapeIntoFields.
private List<Field> processDataShapeIntoFields(String stepSpecification, DataShapeKinds dsKind) {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
List<Field> fields = null;
log.debug(stepSpecification);
if (dsKind.equals(DataShapeKinds.JAVA)) {
try {
JavaClass jClass = mapper.readValue(stepSpecification, JavaClass.class);
jClass = mapper.readValue(stepSpecification, JavaClass.class);
List<JavaField> jfields = getJavaFields(jClass);
fields = jfields.stream().map(f -> (Field) f).collect(Collectors.toList());
} catch (IOException e) {
log.error("error: {}" + e);
}
} else if (dsKind.equals(DataShapeKinds.JSON_SCHEMA) || dsKind.equals(DataShapeKinds.JSON_INSTANCE)) {
JsonInspectionResponse inspectionResponse = atlasmapEndpoint.inspectJson(generateJsonInspectionRequest(stepSpecification));
try {
String mapperString = mapper.writeValueAsString(inspectionResponse);
log.debug(mapperString);
fields = inspectionResponse.getJsonDocument().getFields().getField();
} catch (JsonProcessingException e) {
log.error("error: {}" + e);
}
} else if (dsKind.equals(DataShapeKinds.XML_SCHEMA) || dsKind.equals(DataShapeKinds.XML_INSTANCE)) {
// TODO(tplevko)
throw new UnsupportedOperationException("XML support is not implemented yet");
}
return fields;
}
use of com.google.firestore.admin.v1.Field 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 com.google.firestore.admin.v1.Field in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionService method processActions.
@Override
public void processActions(Actions actions, Field field) throws AtlasException {
Field tmpField = internalProcessActions(actions, field.getValue(), field.getFieldType());
field.setValue(tmpField.getValue());
field.setFieldType(tmpField.getFieldType());
}
Aggregations