use of org.mycore.pi.backend.MCRPI in project mycore by MyCoRe-Org.
the class MCRDOIRegistrationService method insertIdentifierToDatabase.
@Override
public MCRPI insertIdentifierToDatabase(MCRBase obj, String additional, MCRDigitalObjectIdentifier identifier) {
Date registrationStarted = null;
if (getRegistrationCondition(obj.getId().getTypeId()).test(obj)) {
registrationStarted = new Date();
startRegisterJob(obj, identifier);
}
MCRPI databaseEntry = new MCRPI(identifier.asString(), getType(), obj.getId().toString(), additional, this.getRegistrationServiceID(), provideRegisterDate(obj, additional), registrationStarted);
MCRHIBConnection.instance().getSession().save(databaseEntry);
return databaseEntry;
}
use of org.mycore.pi.backend.MCRPI in project mycore by MyCoRe-Org.
the class MCRPURLJobRegistrationService method insertIdentifierToDatabase.
@Override
public MCRPI insertIdentifierToDatabase(MCRBase obj, String additional, MCRPersistentUniformResourceLocator identifier) {
Date registrationStarted = null;
if (getRegistrationCondition(obj.getId().getTypeId()).test(obj)) {
registrationStarted = new Date();
startRegisterJob(obj, identifier);
}
MCRPI databaseEntry = new MCRPI(identifier.asString(), getType(), obj.getId().toString(), additional, this.getRegistrationServiceID(), provideRegisterDate(obj, additional), registrationStarted);
MCRHIBConnection.instance().getSession().save(databaseEntry);
return databaseEntry;
}
use of org.mycore.pi.backend.MCRPI in project mycore by MyCoRe-Org.
the class MCRURNGranularOAIRegistrationService method registerSingleURN.
private MCRDNBURN registerSingleURN(MCRBase obj, String additional, MCRObjectDerivate derivate) throws MCRPersistentIdentifierException {
MCRDNBURN newURN;
LOGGER.info("Add single urn to {} / {}", obj.getId(), additional);
Session session = MCRHIBConnection.instance().getSession();
MCRPath filePath;
if (!Files.exists(filePath = MCRPath.getPath(obj.getId().toString(), additional))) {
throw new MCRPersistentIdentifierException("Invalid path : " + additional);
}
int count = Math.toIntExact(derivate.getFileMetadata().stream().filter(file -> file.getUrn() != null).count());
MCRDNBURN dnbURN = newURN = (MCRDNBURN) MCRPersistentIdentifierManager.getInstance().get(derivate.getURN()).findFirst().get();
String setID = obj.getId().getNumberAsString();
MCRDNBURN urntoAssign = dnbURN.toGranular(setID, count + 1, count + 1);
derivate.getOrCreateFileMetadata(filePath, urntoAssign.asString()).setUrn(urntoAssign.asString());
MCRPI databaseEntry = new MCRPI(urntoAssign.asString(), getType(), obj.getId().toString(), additional, this.getRegistrationServiceID(), new Date());
session.save(databaseEntry);
return newURN;
}
Aggregations