use of com.google.firestore.admin.v1.Field in project atlasmap by atlasmap.
the class XmlModule method writeTargetValue.
@Override
public void writeTargetValue(AtlasInternalSession session) throws AtlasException {
XmlFieldWriter writer = session.getFieldWriter(getDocId(), XmlFieldWriter.class);
if (session.head().getTargetField() instanceof FieldGroup) {
FieldGroup targetFieldGroup = (FieldGroup) session.head().getTargetField();
if (targetFieldGroup.getField().size() > 0) {
for (Field f : targetFieldGroup.getField()) {
session.head().setTargetField(f);
writer.write(session);
}
return;
}
}
writer.write(session);
}
use of com.google.firestore.admin.v1.Field in project atlasmap by atlasmap.
the class DefaultAtlasContext method processSourceFieldGroup.
private void processSourceFieldGroup(DefaultAtlasSession session, FieldGroup sourceFieldGroup) throws AtlasException {
processSourceFields(session, sourceFieldGroup.getField());
session.head().setSourceField(sourceFieldGroup);
Field processed = applyFieldActions(session, session.head().getSourceField());
session.head().setSourceField(processed);
}
use of com.google.firestore.admin.v1.Field in project atlasmap by atlasmap.
the class DefaultAtlasContext method processSeparateField.
/**
* @deprecated .
* @param session session
* @param mapping mapping
* @param sourceField source field
* @return processed
* @throws AtlasException .
*/
@Deprecated
protected List<Field> processSeparateField(DefaultAtlasSession session, Mapping mapping, Field sourceField) throws AtlasException {
if (sourceField.getValue() == null) {
AtlasUtil.addAudit(session, sourceField, String.format("null value can't be separated for sourceField.path=%s", sourceField.getPath()), AuditStatus.WARN, null);
return null;
}
if (!sourceField.getValue().getClass().isAssignableFrom(String.class)) {
Object converted = factory.getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), FieldType.STRING, null);
sourceField.setValue(converted);
}
List<Field> answer = new ArrayList<>();
String sourceValue;
try {
sourceValue = (String) factory.getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), FieldType.STRING, null);
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, sourceField, String.format("Suitable converter for sourceField.path=%s hasn't been found", sourceField.getPath()), AuditStatus.WARN, null);
sourceValue = sourceField.getValue().toString();
}
List<String> separatedValues = null;
StringDelimiter delimiter = StringDelimiter.fromName(mapping.getDelimiter());
if (delimiter != null) {
separatedValues = factory.getSeparateStrategy().separateValue(sourceValue, delimiter);
} else {
separatedValues = factory.getSeparateStrategy().separateValue(sourceValue);
}
if (separatedValues == null || separatedValues.isEmpty()) {
LOG.debug("Empty string for Separate mapping sourceField.path={}", sourceField.getPath());
} else {
for (String separatedValue : separatedValues) {
SimpleField simpleField = AtlasModelFactory.cloneFieldToSimpleField(sourceField);
simpleField.setValue(separatedValue);
simpleField.setFieldType(FieldType.STRING);
answer.add(simpleField);
}
}
return answer;
}
use of com.google.firestore.admin.v1.Field in project atlasmap by atlasmap.
the class DefaultAtlasContext method processCombineField.
/**
* @deprecated .
* @param session session
* @param mapping mapping
* @param sourceFields source fields
* @param targetField target field
* @return processed
*/
@Deprecated
protected Field processCombineField(DefaultAtlasSession session, Mapping mapping, List<Field> sourceFields, Field targetField) {
Map<Integer, String> combineValues = null;
for (Field sourceField : sourceFields) {
if (sourceField.getIndex() == null || sourceField.getIndex() < 0) {
AtlasUtil.addAudit(session, targetField, String.format("Combine requires zero or positive Index value to be set on all sourceFields sourceField.path=%s", sourceField.getPath()), AuditStatus.WARN, null);
continue;
}
if (combineValues == null) {
// We need to support a sorted map w/ null values
combineValues = new HashMap<>();
}
if (sourceField.getValue() != null) {
String sourceValue;
try {
sourceValue = (String) factory.getConversionService().convertType(sourceField.getValue(), sourceField.getFormat(), FieldType.STRING, null);
} catch (AtlasConversionException e) {
AtlasUtil.addAudit(session, targetField, String.format("Suitable converter for sourceField.path=%s hasn't been found", sourceField.getPath()), AuditStatus.WARN, null);
sourceValue = sourceField.getValue() != null ? sourceField.getValue().toString() : null;
}
combineValues.put(sourceField.getIndex(), sourceValue);
}
}
String combinedValue = null;
StringDelimiter delimiter = StringDelimiter.fromName(mapping.getDelimiter());
if (delimiter != null) {
combinedValue = factory.getCombineStrategy().combineValues(combineValues, delimiter);
} else if (mapping.getDelimiterString() != null && !mapping.getDelimiterString().isEmpty()) {
combinedValue = factory.getCombineStrategy().combineValues(combineValues, mapping.getDelimiterString());
} else {
combinedValue = factory.getCombineStrategy().combineValues(combineValues);
}
Field answer = AtlasModelFactory.cloneFieldToSimpleField(sourceFields.get(0));
if (combinedValue == null || combinedValue.trim().isEmpty()) {
LOG.debug("Empty combined string for Combine mapping targetField.path={}", targetField.getPath());
} else {
answer.setValue(combinedValue);
}
return answer;
}
use of com.google.firestore.admin.v1.Field in project atlasmap by atlasmap.
the class DefaultAtlasContext method processSourceFields.
private void processSourceFields(DefaultAtlasSession session, List<Field> sourceFields) throws AtlasException {
for (int i = 0; i < sourceFields.size(); i++) {
Field sourceField = sourceFields.get(i);
session.head().setSourceField(sourceField);
if (sourceField instanceof FieldGroup) {
processSourceFields(session, ((FieldGroup) sourceField).getField());
Field processed = applyFieldActions(session, sourceField);
session.head().setSourceField(processed);
continue;
}
AtlasModule module = resolveModule(FieldDirection.SOURCE, sourceField);
if (module == null) {
AtlasUtil.addAudit(session, sourceField, String.format("Module not found for docId '%s'", sourceField.getDocId()), AuditStatus.ERROR, null);
return;
}
if (!module.isSupportedField(sourceField)) {
AtlasUtil.addAudit(session, sourceField, String.format("Unsupported source field type '%s' for DataSource '%s'", sourceField.getClass().getName(), module.getUri()), AuditStatus.ERROR, null);
return;
}
module.readSourceValue(session);
Field processed = applyFieldActions(session, session.head().getSourceField());
session.head().setSourceField(processed);
sourceFields.set(i, processed);
}
}
Aggregations