Search in sources :

Example 6 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class RepositoryObjectLoaderTest method getDepositRecordTest.

@Test
public void getDepositRecordTest() {
    PID pid = pidMinter.mintDepositRecordPid();
    when(objectCacheLoader.load(eq(pid))).thenReturn(mock(DepositRecord.class));
    assertNotNull(repoObjLoader.getDepositRecord(pid));
}
Also used : PID(edu.unc.lib.boxc.model.api.ids.PID) DepositRecord(edu.unc.lib.boxc.model.api.objects.DepositRecord) Test(org.junit.Test)

Example 7 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class WorkObjectTest method setPrimaryObjectToInvalidTypeTest.

@Test(expected = InvalidOperationForObjectType.class)
public void setPrimaryObjectToInvalidTypeTest() {
    PID anotherPid = makePid();
    WorkObject anotherWork = mock(WorkObject.class);
    when(anotherWork.getPid()).thenReturn(anotherPid);
    when(driver.getRepositoryObject(eq(anotherPid))).thenReturn(anotherWork);
    try {
        work.setPrimaryObject(anotherPid);
    } finally {
        verify(repoObjFactory, never()).createExclusiveRelationship(any(RepositoryObject.class), eq(Cdr.primaryObject), any(Resource.class));
    }
}
Also used : RepositoryObject(edu.unc.lib.boxc.model.api.objects.RepositoryObject) WorkObject(edu.unc.lib.boxc.model.api.objects.WorkObject) Resource(org.apache.jena.rdf.model.Resource) ResourceFactory.createResource(org.apache.jena.rdf.model.ResourceFactory.createResource) PID(edu.unc.lib.boxc.model.api.ids.PID) Test(org.junit.Test)

Example 8 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class DepositRecordImpl method addPidsToList.

private List<PID> addPidsToList(Property p) {
    Resource resource = getResource();
    StmtIterator containsIt = resource.listProperties(p);
    List<PID> pids = new ArrayList<>();
    while (containsIt.hasNext()) {
        String path = containsIt.next().getObject().toString();
        pids.add(PIDs.get(path));
    }
    return pids;
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Resource(org.apache.jena.rdf.model.Resource) ArrayList(java.util.ArrayList) PID(edu.unc.lib.boxc.model.api.ids.PID)

Example 9 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class FileObjectImpl method getBinaryObjects.

/**
 * Retrieve all of the binary objects contained by this FileObject.
 *
 * @return List of contained binary objects
 */
@Override
public List<BinaryObject> getBinaryObjects() {
    Resource resc = getResource();
    List<BinaryObject> binaries = new ArrayList<>();
    for (StmtIterator it = resc.listProperties(PcdmModels.hasFile); it.hasNext(); ) {
        PID binaryPid = PIDs.get(it.nextStatement().getResource().getURI());
        binaries.add(driver.getRepositoryObject(binaryPid, BinaryObject.class));
    }
    return binaries;
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) BinaryObject(edu.unc.lib.boxc.model.api.objects.BinaryObject) Resource(org.apache.jena.rdf.model.Resource) ResourceFactory.createResource(org.apache.jena.rdf.model.ResourceFactory.createResource) ArrayList(java.util.ArrayList) PID(edu.unc.lib.boxc.model.api.ids.PID)

Example 10 with PID

use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.

the class RepositoryObjectFactoryImpl method deleteProperty.

/**
 * Deletes all triples with the given property predicate from the specified repository object.
 * @param repoObj repository object to remove properties from
 * @param property predicate of properties to remove
 */
@Override
public void deleteProperty(RepositoryObject repoObj, Property property) {
    PID subject = repoObj.getPid();
    String sparqlUpdate = SparqlUpdateHelper.createSparqlDelete(subject.getRepositoryPath(), property, null);
    sparqlUpdateService.executeUpdate(repoObj.getMetadataUri().toString(), sparqlUpdate);
    repoObj.shouldRefresh();
}
Also used : PID(edu.unc.lib.boxc.model.api.ids.PID)

Aggregations

PID (edu.unc.lib.boxc.model.api.ids.PID)735 Test (org.junit.Test)509 Model (org.apache.jena.rdf.model.Model)130 Resource (org.apache.jena.rdf.model.Resource)122 Bag (org.apache.jena.rdf.model.Bag)100 Matchers.anyString (org.mockito.Matchers.anyString)89 RoleAssignment (edu.unc.lib.boxc.auth.api.models.RoleAssignment)85 MvcResult (org.springframework.test.web.servlet.MvcResult)78 CollectionObject (edu.unc.lib.boxc.model.api.objects.CollectionObject)65 RepositoryObject (edu.unc.lib.boxc.model.api.objects.RepositoryObject)63 AdminUnit (edu.unc.lib.boxc.model.api.objects.AdminUnit)62 WorkObject (edu.unc.lib.boxc.model.api.objects.WorkObject)62 URI (java.net.URI)62 FileObject (edu.unc.lib.boxc.model.api.objects.FileObject)61 AbstractDepositJobTest (edu.unc.lib.boxc.deposit.fcrepo4.AbstractDepositJobTest)55 BinaryObject (edu.unc.lib.boxc.model.api.objects.BinaryObject)50 Document (org.jdom2.Document)50 FolderObject (edu.unc.lib.boxc.model.api.objects.FolderObject)48 File (java.io.File)48 Path (java.nio.file.Path)48