use of net.geoprism.registry.etl.export.dhis2.MissingDHIS2TermOrgUnitGroupMapping in project geoprism-registry by terraframe.
the class DHIS2TermAttributeMapping method writeCustomAttributes.
@Override
public void writeCustomAttributes(JsonArray attributeValues, VertexServerGeoObject serverGo, DHIS2SyncConfig dhis2Config, DHIS2SyncLevel syncLevel, String lastUpdateDate, String createDate) {
ServerGeoObjectType got = syncLevel.getGeoObjectType();
AttributeType attr = got.getAttribute(this.getCgrAttrName()).get();
Object value = serverGo.getValue(attr.getName());
if (value == null || (value instanceof String && ((String) value).length() == 0)) {
return;
}
if (this.isOrgUnitGroup()) {
if (attr instanceof AttributeTermType) {
String termId = this.getTermId(value);
String orgUnitGroupId = this.getTermMapping(termId);
if (orgUnitGroupId == null) {
MissingDHIS2TermOrgUnitGroupMapping ex = new MissingDHIS2TermOrgUnitGroupMapping();
ex.setTermCode(termId);
throw ex;
}
Set<String> orgUnitGroupIdSet = syncLevel.getOrgUnitGroupIdSet(orgUnitGroupId);
if (orgUnitGroupIdSet == null) {
orgUnitGroupIdSet = syncLevel.newOrgUnitGroupIdSet(orgUnitGroupId);
}
orgUnitGroupIdSet.add(serverGo.getExternalId(dhis2Config.getSystem()));
} else {
logger.error("Unsupported attribute type [" + attr.getClass().getName() + "] with name [" + attr.getName() + "] when matched to OrgUnitGroup.");
return;
}
} else {
super.writeCustomAttributes(attributeValues, serverGo, dhis2Config, syncLevel, lastUpdateDate, createDate);
}
}
Aggregations