use of org.orcid.pojo.IdentifierType in project ORCID-Source by ORCID.
the class WorksController method searchExternalIDTypes.
/**
* Search DB for id types to suggest to user
* if list empty, suggest the top ten.
*/
@RequestMapping(value = "/idTypes.json", method = RequestMethod.GET)
@ResponseBody
public List<Map<String, String>> searchExternalIDTypes(@RequestParam("query") String query) {
List<Map<String, String>> datums = new ArrayList<>();
//fetch results
List<IdentifierType> types;
if (query == null || query.trim().isEmpty()) {
types = identifierTypeManager.fetchDefaultIdentifierTypes(getLocale());
} else {
types = identifierTypeManager.queryByPrefix(query, getLocale());
}
//format for output
for (IdentifierType t : types) {
if (IdentifierType.PRIMARY_USE_WORK.equals(t.getPrimaryUse())) {
Map<String, String> datum1 = new HashMap<String, String>();
datum1.put("name", t.getName());
datum1.put("description", t.getDescription());
datum1.put("resolutionPrefix", t.getResolutionPrefix());
datums.add(datum1);
}
}
return datums;
}
use of org.orcid.pojo.IdentifierType in project ORCID-Source by ORCID.
the class IdentifierTypeManagerTest method test1FetchIdentifier.
@Test
public void test1FetchIdentifier() {
IdentifierType id = idTypeMan.fetchIdentifierTypeByDatabaseName("DOI", Locale.FRANCE);
assertEquals("doi", id.getName());
assertEquals("doi: Identificateur dobjet numérique", id.getDescription());
id = idTypeMan.fetchIdentifierTypeByDatabaseName("OTHER_ID", null);
assertEquals("other-id", id.getName());
assertFalse(id.getCaseSensitive());
assertEquals("Other identifier type", id.getDescription());
}
use of org.orcid.pojo.IdentifierType in project ORCID-Source by ORCID.
the class IdentifierTypeManagerTest method testPrefixSearch.
public void testPrefixSearch() {
List<IdentifierType> types = idTypeMan.queryByPrefix("do", null);
boolean foundDOI = false;
boolean foundASIN = false;
boolean foundScopus = false;
for (IdentifierType t : types) {
if (t.getName().equals("doi"))
foundDOI = true;
if (// has "domain" in the description
t.getName().equals("asin-tld"))
foundASIN = true;
if (t.getName().equals("eid"))
foundScopus = true;
}
assertTrue(foundDOI);
assertTrue(foundASIN);
assertFalse(foundScopus);
}
use of org.orcid.pojo.IdentifierType in project ORCID-Source by ORCID.
the class IdentifierTypeManagerTest method test2CreateAndUpdateIdentifier.
@Test
@Transactional
@Rollback
public void test2CreateAndUpdateIdentifier() {
IdentifierType id = idTypeMan.createIdentifierType(createIdentifierType(1));
assertNotNull(id);
assertNotNull(id.getPutCode());
assertTrue(new Date().after(id.getDateCreated()));
id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
assertNotNull(id);
id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
Date last = id.getLastModified();
id.setValidationRegex("test");
id = idTypeMan.updateIdentifierType(id);
assertTrue(last.before(id.getLastModified()));
id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
assertEquals("test1", id.getName());
assertEquals("test", id.getValidationRegex());
assertTrue(last.getTime() < id.getLastModified().getTime());
}
Aggregations