Skip to content

Commit

Permalink
Merge pull request #28 from aodn/fix-provider
Browse files Browse the repository at this point in the history
Put provider into a list
  • Loading branch information
vietnguyengit authored Nov 21, 2023
2 parents 7e41f97 + d007728 commit 43bd250
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class StacCollectionModel {
protected List<LanguageModel> languages;
protected List<LinkModel> links;
protected String license;
protected ProviderModel provider;
protected List<ProviderModel> providers;

@JsonProperty("stac_version")
public String getStacVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public abstract class StacCollectionMapperServiceImpl implements StacCollectionM
@Mapping(target="languages", source = "source", qualifiedByName = "mapLanguages")
@Mapping(target="links", source = "source", qualifiedByName = "mapLinks")
@Mapping(target="license", source = "source", qualifiedByName = "mapLicense")
@Mapping(target="provider", source = "source", qualifiedByName = "mapProvider")
@Mapping(target="providers", source = "source", qualifiedByName = "mapProviders")
public abstract StacCollectionModel mapToSTACCollection(MDMetadataType source);

private static final Logger logger = LoggerFactory.getLogger(StacCollectionMapperServiceImpl.class);
Expand Down Expand Up @@ -384,15 +384,15 @@ List<LinkModel> mapLinks(MDMetadataType source) {
}

// TODO: need to handle exception
@Named("mapProvider")
ProviderModel mapProvider(MDMetadataType source) {
ProviderModel providerModel = ProviderModel.builder().build();

@Named("mapProviders")
List<ProviderModel> mapProviders(MDMetadataType source) {
List<ProviderModel> results = new ArrayList<>();
source.getContact().forEach(item -> {
if (item.getAbstractResponsibility().getValue() instanceof CIResponsibilityType2 ciResponsibility) {
providerModel.setRoles(Collections.singletonList(ciResponsibility.getRole().getCIRoleCode().getCodeListValue()));
ciResponsibility.getParty().forEach(party -> {
try {
ProviderModel providerModel = ProviderModel.builder().build();
providerModel.setRoles(Collections.singletonList(ciResponsibility.getRole().getCIRoleCode().getCodeListValue()));
CIOrganisationType2 organisationType2 = (CIOrganisationType2) party.getAbstractCIParty().getValue();
providerModel.setName(organisationType2.getName().getCharacterString().getValue().toString());
organisationType2.getIndividual().forEach(individual -> {
Expand All @@ -402,13 +402,14 @@ ProviderModel mapProvider(MDMetadataType source) {
});
});
});
results.add(providerModel);
} catch (ClassCastException e) {
logger.error("Unable to cast getAbstractCIParty().getValue() to CIOrganisationType2 for metadata record: " + this.mapUUID(source));
}
});
}
});
return providerModel;
return results;
}

@Named("mapLicense")
Expand Down

0 comments on commit 43bd250

Please sign in to comment.