use of net.geoprism.dhis2.dhis2adapter.response.model.OptionSet in project geoprism-registry by terraframe.
the class DHIS2OptionCache method init.
private void init() {
try {
MetadataGetResponse<OptionSet> resp = dhis2.<OptionSet>metadataGet(OptionSet.class);
if (!resp.isSuccess()) {
// if (resp.hasMessage())
// {
// ExportRemoteException ere = new ExportRemoteException();
// ere.setRemoteError(resp.getMessage());
// throw ere;
// }
// else
// {
UnexpectedRemoteResponse re = new UnexpectedRemoteResponse();
throw re;
// }
}
List<OptionSet> objects = resp.getObjects();
this.optionSets = new HashMap<String, IntegratedOptionSet>(objects.size());
for (OptionSet os : objects) {
this.optionSets.put(os.getId(), new IntegratedOptionSet(os));
}
if (this.optionSets.size() > 0) {
MetadataGetResponse<Option> resp2 = dhis2.<Option>metadataGet(Option.class);
if (!resp2.isSuccess()) {
// if (resp.hasMessage())
// {
// ExportRemoteException ere = new ExportRemoteException();
// ere.setRemoteError(resp.getMessage());
// throw ere;
// }
// else
// {
UnexpectedRemoteResponse re = new UnexpectedRemoteResponse();
throw re;
// }
}
List<Option> options = resp2.getObjects();
for (Option option : options) {
if (option.getOptionSetId() != null && this.optionSets.containsKey(option.getOptionSetId())) {
this.optionSets.get(option.getOptionSetId()).addOption(option);
}
}
}
} catch (InvalidLoginException e) {
LoginException cgrlogin = new LoginException(e);
throw cgrlogin;
} catch (HTTPException e) {
HttpError cgrhttp = new HttpError(e);
throw cgrhttp;
} catch (BadServerUriException e) {
HttpError cgrhttp = new HttpError(e);
throw cgrhttp;
}
}
Aggregations