Search in sources :

Example 1 with MalformedLSIDException

use of com.ibm.lsid.MalformedLSIDException in project cdmlib by cybertaxonomy.

the class BciServiceWrapper method getCollectionFromLine.

private Collection getCollectionFromLine(String line, ICdmRepository appConfig) {
    // urn:lsid:biocol.org:col:15727	http://biocol.org/urn:lsid:biocol.org:col:15727	University of Bergen Herbarium
    String[] splits = line.split("\t");
    if (splits.length != 3) {
        logger.warn("Unknwon BCI line format: " + line);
        return null;
    }
    String lsidString = splits[0];
    String urlString = splits[1];
    String collectionName = splits[2];
    Collection result = Collection.NewInstance();
    // LSID
    LSID lsid = null;
    try {
        lsid = new LSID(lsidString);
    } catch (MalformedLSIDException e) {
        logger.warn("Malformed LSID " + lsidString, e);
    }
    result.setLsid(lsid);
    String id = getCollectionId(lsid);
    result.setName(collectionName);
    // id, citation
    Reference citation = getBciCitation(appConfig);
    result.addSource(OriginalSourceType.Lineage, id, null, citation, null);
    return result;
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) Reference(eu.etaxonomy.cdm.model.reference.Reference) Collection(eu.etaxonomy.cdm.model.occurrence.Collection)

Example 2 with MalformedLSIDException

use of com.ibm.lsid.MalformedLSIDException in project cdmlib by cybertaxonomy.

the class LSIDRegistryTest method setUp.

@Before
public void setUp() {
    try {
        lsid = new LSID("urn:lsid:example.org:names:1");
        ipniLsid = new LSID("urn:lsid:ipni.org:names:1");
        unknownAuthorityLsid = new LSID("urn:lsid:fred.org:dagg:1");
    } catch (MalformedLSIDException mle) {
        Assert.fail();
    }
    ((LsidRegistryImpl) lsidRegistry).init();
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) LsidRegistryImpl(eu.etaxonomy.cdm.api.service.lsid.impl.LsidRegistryImpl) Before(org.junit.Before)

Example 3 with MalformedLSIDException

use of com.ibm.lsid.MalformedLSIDException in project cdmlib by cybertaxonomy.

the class TaxonXTreatmentExtractor method setLSID.

/**
 * @param identifier
 * @param acceptedTaxon
 */
@SuppressWarnings("rawtypes")
private void setLSID(String identifier, TaxonBase<?> taxon) {
    // logger.info("setLSID");
    // boolean lsidok=false;
    String id = identifier.split("__")[0];
    String source = identifier.split("__")[1];
    if (id.indexOf("lsid") > -1) {
        try {
            LSID lsid = new LSID(id);
            taxon.setLsid(lsid);
        // lsidok=true;
        } catch (MalformedLSIDException e) {
            logger.warn("Malformed LSID");
        }
    }
    // logger.info("search reference for LSID");
    // if ((id.indexOf("lsid")<0) || !lsidok){
    // ADD ORIGINAL SOURCE ID EVEN IF LSID
    Reference re = null;
    Pager<Reference> references = importer.getReferenceService().findByTitleWithRestrictions(Reference.class, source, MatchMode.EXACT, null, 1, null, null, null);
    if (references != null && references.getCount() > 0) {
        re = references.getRecords().get(0);
    }
    // logger.info("search reference for LSID-end");
    if (re == null) {
        re = ReferenceFactory.newGeneric();
        re.setTitleCache(source, true);
        importer.getReferenceService().saveOrUpdate(re);
    }
    re = CdmBase.deproxy(re, Reference.class);
    // logger.info("search source for LSID");
    Set<IdentifiableSource> sources = taxon.getSources();
    boolean lsidinsource = false;
    boolean urlinsource = false;
    for (IdentifiableSource src : sources) {
        if (id.equalsIgnoreCase(src.getIdInSource()) && re.getTitleCache().equals(src.getCitation().getTitleCache())) {
            lsidinsource = true;
        }
        if (src.getIdInSource() == null && re.getTitleCache().equals(sourceUrlRef.getTitleCache())) {
            urlinsource = true;
        }
    }
    if (!lsidinsource) {
        taxon.addSource(OriginalSourceType.Import, id, null, re, null);
    }
    if (!urlinsource) {
        sourceUrlRef = CdmBase.deproxy(sourceUrlRef, Reference.class);
        taxon.addSource(OriginalSourceType.Import, null, null, sourceUrlRef, null);
    // }
    }
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) Reference(eu.etaxonomy.cdm.model.reference.Reference) IdentifiableSource(eu.etaxonomy.cdm.model.common.IdentifiableSource)

Example 4 with MalformedLSIDException

use of com.ibm.lsid.MalformedLSIDException in project cdmlib by cybertaxonomy.

the class AuthorityControllerTest method setUp.

@Before
public void setUp() {
    try {
        lsid = new LSID("urn:lsid:example.org:taxonconcept:1");
    } catch (MalformedLSIDException e) {
    }
    try {
        lsidAuthority = new LSIDAuthority("fred.org");
    } catch (MalformedLSIDException e) {
    }
    authorityService = org.easymock.classextension.EasyMock.createMock(LSIDAuthorityService.class);
    authorityController = new AuthorityController();
    source = new Object();
    expiringResponse = new ExpiringResponse(source, null);
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) LSIDAuthorityService(eu.etaxonomy.cdm.api.service.lsid.LSIDAuthorityService) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) TestedObject(org.unitils.inject.annotation.TestedObject) LSIDAuthority(eu.etaxonomy.cdm.model.common.LSIDAuthority) ExpiringResponse(com.ibm.lsid.ExpiringResponse) Before(org.junit.Before)

Example 5 with MalformedLSIDException

use of com.ibm.lsid.MalformedLSIDException in project cdmlib by cybertaxonomy.

the class DataControllerTest method setUp.

@Before
public void setUp() {
    try {
        lsid = new LSID("urn:lsid:example.org:taxonconcepts:1");
    } catch (MalformedLSIDException e) {
    }
    dataController = new DataController();
    inputStream = new ByteArrayInputStream(expectedData.getBytes());
    dataService = EasyMock.createMock(LSIDDataService.class);
    response = new MockHttpServletResponse();
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) MalformedLSIDException(com.ibm.lsid.MalformedLSIDException) ByteArrayInputStream(java.io.ByteArrayInputStream) LSIDDataService(eu.etaxonomy.cdm.api.service.lsid.LSIDDataService) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Before(org.junit.Before)

Aggregations

MalformedLSIDException (com.ibm.lsid.MalformedLSIDException)11 LSID (eu.etaxonomy.cdm.model.common.LSID)10 Before (org.junit.Before)4 IdentifiableSource (eu.etaxonomy.cdm.model.common.IdentifiableSource)3 Rights (eu.etaxonomy.cdm.model.media.Rights)3 Reference (eu.etaxonomy.cdm.model.reference.Reference)3 Person (eu.etaxonomy.cdm.model.agent.Person)2 Annotation (eu.etaxonomy.cdm.model.common.Annotation)2 Credit (eu.etaxonomy.cdm.model.common.Credit)2 LSIDAuthority (eu.etaxonomy.cdm.model.common.LSIDAuthority)2 ExpiringResponse (com.ibm.lsid.ExpiringResponse)1 LSIDAuthorityService (eu.etaxonomy.cdm.api.service.lsid.LSIDAuthorityService)1 LSIDDataService (eu.etaxonomy.cdm.api.service.lsid.LSIDDataService)1 LSIDMetadataService (eu.etaxonomy.cdm.api.service.lsid.LSIDMetadataService)1 LsidRegistryImpl (eu.etaxonomy.cdm.api.service.lsid.impl.LsidRegistryImpl)1 URI (eu.etaxonomy.cdm.common.URI)1 Extension (eu.etaxonomy.cdm.model.common.Extension)1 Identifier (eu.etaxonomy.cdm.model.common.Identifier)1 IntextReference (eu.etaxonomy.cdm.model.common.IntextReference)1 Marker (eu.etaxonomy.cdm.model.common.Marker)1