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;
}
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();
}
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);
// }
}
}
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);
}
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();
}
Aggregations