use of org.orcid.pojo.ajaxForm.ImportWizzardClientForm in project ORCID-Source by ORCID.
the class ThirdPartyLinkManagerImpl method generateImportWizzardForm.
private List<ImportWizzardClientForm> generateImportWizzardForm(RedirectUriType rut, Locale locale) {
List<ClientRedirectUriEntity> entitiesWithPredefinedScopes = clientRedirectDao.findClientDetailsWithRedirectScope();
List<ImportWizzardClientForm> clients = new ArrayList<ImportWizzardClientForm>();
for (ClientRedirectUriEntity entity : entitiesWithPredefinedScopes) {
if (rut.value().equals(entity.getRedirectUriType())) {
if (rut.value().equals(entity.getRedirectUriType())) {
ClientDetailsEntity clientDetails = entity.getClientDetailsEntity();
ImportWizzardClientForm clientForm = new ImportWizzardClientForm();
clientForm.setId(clientDetails.getId());
clientForm.setName(clientDetails.getClientName());
clientForm.setDescription(clientDetails.getClientDescription());
clientForm.setRedirectUri(entity.getRedirectUri());
clientForm.setScopes(entity.getPredefinedClientScope());
if (RedirectUriType.IMPORT_WORKS_WIZARD.equals(rut)) {
if (!PojoUtil.isEmpty(entity.getUriActType())) {
JsonNode node = JsonUtils.readTree(entity.getUriActType());
List<String> elements = new ArrayList<String>();
if (node.has("import-works-wizard")) {
node.get("import-works-wizard").forEach(x -> {
String value = x.asText();
switch(value) {
case "Articles":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.work_type.articles", locale));
break;
case "Data":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.work_type.books", locale));
break;
case "Books":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.work_type.data", locale));
break;
case "Student Publications":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.work_type.student_publications", locale));
break;
default:
elements.add(value);
break;
}
});
}
clientForm.setActTypes(elements);
}
if (!PojoUtil.isEmpty(entity.getUriActType())) {
JsonNode node = JsonUtils.readTree(entity.getUriGeoArea());
List<String> elements = new ArrayList<String>();
if (node.has("import-works-wizard")) {
node.get("import-works-wizard").forEach(x -> {
String value = x.asText();
switch(value) {
case "Africa":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.africa", locale));
break;
case "Asia":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.asia", locale));
break;
case "Australia":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.australia", locale));
break;
case "Europe":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.europe", locale));
break;
case "Global":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.global", locale));
break;
case "North America":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.north_america", locale));
break;
case "South America":
elements.add(localeManager.resolveMessage("workspace.works.import_wizzard.geo_area.south_america", locale));
break;
default:
elements.add(value);
break;
}
});
}
clientForm.setGeoAreas(elements);
}
}
clients.add(clientForm);
}
}
}
return clients;
}
use of org.orcid.pojo.ajaxForm.ImportWizzardClientForm in project ORCID-Source by ORCID.
the class WorkspaceController method getSourceGrantReadWizard.
@RequestMapping(value = "/my-orcid/sourceGrantReadWizard.json", method = RequestMethod.GET)
@ResponseBody
public ThirdPartyRedirect getSourceGrantReadWizard() {
ThirdPartyRedirect tpr = new ThirdPartyRedirect();
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
if (profile.getSource() == null || profile.getSource().getSourceId() == null) {
return tpr;
}
String sourcStr = profile.getSource().getSourceId();
// Check that the cache is up to date
evictThirdPartyLinkManagerCacheIfNeeded();
// Get list of clients
List<ImportWizzardClientForm> clients = thirdPartyLinkManager.findOrcidClientsWithPredefinedOauthScopeReadAccess(localeManager.getLocale());
for (ImportWizzardClientForm client : clients) {
if (sourcStr.equals(client.getId())) {
String redirect = getBaseUri() + "/oauth/authorize?client_id=" + client.getId() + "&response_type=code&scope=" + client.getScopes() + "&redirect_uri=" + client.getRedirectUri();
tpr.setUrl(redirect);
tpr.setDisplayName(client.getName());
tpr.setShortDescription(client.getDescription());
return tpr;
}
}
return tpr;
}
Aggregations