Search in sources :

Example 1 with ISysRelationsStream

use of dk.dbc.opensearch.commons.repository.ISysRelationsStream in project solr-document-store by DBCDK.

the class SolrIndexer method unitFor.

@Lock(LockType.READ)
public String unitFor(String pid) throws RepositoryException {
    try (IRepositoryDAO dao = daoProvider.getRepository()) {
        IRepositoryIdentifier id = dao.createIdentifier(pid);
        if (!dao.hasObject(id)) {
            throw new IllegalStateException("Doesn't have pid: " + pid);
        }
        if (dao.getObjectState(id) == IRepositoryDAO.State.DELETED) {
            return null;
        }
        ISysRelationsStream relations = dao.getSysRelationsStream(id);
        IRepositoryIdentifier unit = relations.getUnitFor();
        return unit.toString();
    }
}
Also used : ISysRelationsStream(dk.dbc.opensearch.commons.repository.ISysRelationsStream) IRepositoryIdentifier(dk.dbc.opensearch.commons.repository.IRepositoryIdentifier) IRepositoryDAO(dk.dbc.opensearch.commons.repository.IRepositoryDAO) Lock(javax.ejb.Lock)

Example 2 with ISysRelationsStream

use of dk.dbc.opensearch.commons.repository.ISysRelationsStream in project solr-document-store by DBCDK.

the class SolrIndexer method workFor.

@Lock(LockType.READ)
public String workFor(String unit) throws RepositoryException {
    if (unit == null) {
        return null;
    }
    try (IRepositoryDAO dao = daoProvider.getRepository()) {
        ISysRelationsStream relations = dao.getSysRelationsStream(dao.createIdentifier(unit));
        IRepositoryIdentifier work = relations.getWorkFor();
        return work.toString();
    }
}
Also used : ISysRelationsStream(dk.dbc.opensearch.commons.repository.ISysRelationsStream) IRepositoryIdentifier(dk.dbc.opensearch.commons.repository.IRepositoryIdentifier) IRepositoryDAO(dk.dbc.opensearch.commons.repository.IRepositoryDAO) Lock(javax.ejb.Lock)

Aggregations

IRepositoryDAO (dk.dbc.opensearch.commons.repository.IRepositoryDAO)2 IRepositoryIdentifier (dk.dbc.opensearch.commons.repository.IRepositoryIdentifier)2 ISysRelationsStream (dk.dbc.opensearch.commons.repository.ISysRelationsStream)2 Lock (javax.ejb.Lock)2