Search in sources :

Example 1 with LSID

use of eu.etaxonomy.cdm.model.common.LSID 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 LSID

use of eu.etaxonomy.cdm.model.common.LSID in project cdmlib by cybertaxonomy.

the class LSIDAuthorityServiceTest method setUp.

@Before
public void setUp() throws Exception {
    unknownLsid = new LSID("fred.org", "dagg", "1", null);
    knownLsid = new LSID("example.org", "taxonconcepts", "1", null);
    XMLUnit.setControlParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    XMLUnit.setTestParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    XMLUnit.setSAXParserFactory("org.apache.xerces.jaxp.SAXParserFactoryImpl");
    XMLUnit.setIgnoreWhitespace(true);
    ((LsidRegistryImpl) lsidRegistry).init();
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) LsidRegistryImpl(eu.etaxonomy.cdm.api.service.lsid.impl.LsidRegistryImpl) Before(org.junit.Before)

Example 3 with LSID

use of eu.etaxonomy.cdm.model.common.LSID in project cdmlib by cybertaxonomy.

the class LSIDMetadataServiceTest method setUp.

@Before
public void setUp() throws Exception {
    lsid = new LSID("example.org", "taxonconcepts", "1", null);
    ((LsidRegistryImpl) lsidRegistry).init();
}
Also used : LSID(eu.etaxonomy.cdm.model.common.LSID) LsidRegistryImpl(eu.etaxonomy.cdm.api.service.lsid.impl.LsidRegistryImpl) Before(org.junit.Before)

Example 4 with LSID

use of eu.etaxonomy.cdm.model.common.LSID 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 5 with LSID

use of eu.etaxonomy.cdm.model.common.LSID 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)

Aggregations

LSID (eu.etaxonomy.cdm.model.common.LSID)27 MalformedLSIDException (com.ibm.lsid.MalformedLSIDException)10 Before (org.junit.Before)10 Test (org.junit.Test)10 DateTime (org.joda.time.DateTime)7 Reference (eu.etaxonomy.cdm.model.reference.Reference)5 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)5 LsidRegistryImpl (eu.etaxonomy.cdm.api.service.lsid.impl.LsidRegistryImpl)4 URI (eu.etaxonomy.cdm.common.URI)4 AuditEvent (eu.etaxonomy.cdm.model.view.AuditEvent)4 AuditEventRecordImpl (eu.etaxonomy.cdm.model.view.AuditEventRecordImpl)4 IdentifiableSource (eu.etaxonomy.cdm.model.common.IdentifiableSource)3 CdmIntegrationTest (eu.etaxonomy.cdm.test.integration.CdmIntegrationTest)3 ExpiringResponse (com.ibm.lsid.ExpiringResponse)2 DefaultPagerImpl (eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl)2 Person (eu.etaxonomy.cdm.model.agent.Person)2 Rights (eu.etaxonomy.cdm.model.media.Rights)2 Synonym (eu.etaxonomy.cdm.model.taxon.Synonym)2 TaxonBase (eu.etaxonomy.cdm.model.taxon.TaxonBase)2 TaxonRelationship (eu.etaxonomy.cdm.model.taxon.TaxonRelationship)2