Search in sources :

Example 11 with IdentifierType

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) LanguagesMap(org.orcid.frontend.web.util.LanguagesMap) SortedMap(java.util.SortedMap) IdentifierType(org.orcid.pojo.IdentifierType) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with IdentifierType

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());
}
Also used : IdentifierType(org.orcid.pojo.IdentifierType) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 13 with IdentifierType

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);
}
Also used : IdentifierType(org.orcid.pojo.IdentifierType)

Example 14 with IdentifierType

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());
}
Also used : IdentifierType(org.orcid.pojo.IdentifierType) Date(java.util.Date) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

IdentifierType (org.orcid.pojo.IdentifierType)14 Test (org.junit.Test)6 Date (java.util.Date)5 BaseTest (org.orcid.core.BaseTest)4 IdentifierTypeEntity (org.orcid.persistence.jpa.entities.IdentifierTypeEntity)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 List (java.util.List)2 GenericEntity (javax.ws.rs.core.GenericEntity)2 Response (javax.ws.rs.core.Response)2 IdentifierTypePOJOConverter (org.orcid.core.adapter.impl.IdentifierTypePOJOConverter)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Builder (com.google.common.collect.ImmutableList.Builder)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1