Search in sources :

Example 1 with Datastream

use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.

the class ExportCsvService method printObject.

private void printObject(CSVPrinter printer, ContentObjectRecord object) throws IOException {
    // Vitals: object type, pid, title, path, label, depth
    printer.print(object.getResourceType());
    printer.print(object.getId());
    printer.print(object.getTitle());
    printer.print(object.getAncestorNames());
    String label = object.getLabel();
    if (label != null) {
        printer.print(label);
    } else {
        printer.print("");
    }
    printer.print(object.getAncestorPathFacet().getHighestTier());
    if (object.getStatus() != null) {
        printer.print(object.getStatus().contains(MARKED_FOR_DELETION));
    } else {
        printer.print("");
    }
    // Dates: added, updated
    Date added = object.getDateAdded();
    if (added != null) {
        printer.print(dateFormat.format(added));
    } else {
        printer.print("");
    }
    Date updated = object.getDateUpdated();
    if (updated != null) {
        printer.print(dateFormat.format(updated));
    } else {
        printer.print("");
    }
    // DATA_FILE info: mime type, checksum, file size
    Datastream dataFileDatastream = object.getDatastreamObject(ORIGINAL_FILE.getId());
    if (dataFileDatastream != null) {
        printer.print(dataFileDatastream.getMimetype());
        printer.print(dataFileDatastream.getChecksum().replace("urn:", ""));
        Long filesize = dataFileDatastream.getFilesize();
        // If we don't have a filesize for whatever reason, print a blank
        if (filesize != null && filesize >= 0) {
            printer.print(filesize);
        } else {
            printer.print("");
        }
    } else {
        printer.print("");
        printer.print("");
        printer.print("");
    }
    // Container info: child count
    Long childCount = object.getCountMap().get("child");
    if (childCount != null && childCount > 0) {
        printer.print(childCount.toString());
    } else {
        printer.print("");
    }
    // Description: does object have a MODS description?
    List<String> contentStatus = object.getContentStatus();
    if (contentStatus != null && contentStatus.contains(FacetConstants.CONTENT_NOT_DESCRIBED)) {
        printer.print(FacetConstants.CONTENT_NOT_DESCRIBED);
    } else if (contentStatus != null && contentStatus.contains(FacetConstants.CONTENT_DESCRIBED)) {
        printer.print(FacetConstants.CONTENT_DESCRIBED);
    } else {
        printer.print("");
    }
    // Patron permissions
    String computedPermissions = computePatronPermissions(object.getRoleGroup());
    printer.print(computedPermissions);
    // Is object embargoed
    List<String> objStatus = object.getStatus();
    printer.print(objStatus != null && objStatus.contains(FacetConstants.EMBARGOED));
    printer.println();
}
Also used : Datastream(edu.unc.lib.boxc.search.api.models.Datastream) Date(java.util.Date)

Example 2 with Datastream

use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.

the class RunEnhancementsService method createMessage.

private void createMessage(ContentObjectRecord metadata, String username, Boolean force) {
    PID pid = metadata.getPid();
    Datastream originalDs = metadata.getDatastreamObject(ORIGINAL_FILE.getId());
    String resourceType = metadata.getResourceType();
    PID originalPid = (ResourceType.File.equals(resourceType) && originalDs != null) ? DatastreamPids.getOriginalFilePid(pid) : pid;
    Document msg = makeEnhancementOperationBody(username, originalPid, force);
    messageSender.sendMessage(msg);
}
Also used : Datastream(edu.unc.lib.boxc.search.api.models.Datastream) PID(edu.unc.lib.boxc.model.api.ids.PID) Document(org.jdom2.Document)

Example 3 with Datastream

use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.

the class LorisContentService method createCanvas.

private Canvas createCanvas(String path, ContentObjectRecord briefObj) {
    String title = getTitle(briefObj);
    String uuid = jp2Pid(briefObj);
    Canvas canvas = new Canvas(path, title);
    if (StringUtils.isEmpty(uuid)) {
        LOG.warn("No jp2 id was found for {}. IIIF canvas is empty.", briefObj.getId());
        return canvas;
    }
    String canvasPath = URIUtil.join(basePath, "jp2Proxy", uuid, "jp2");
    Datastream fileDs = briefObj.getDatastreamObject(DatastreamType.ORIGINAL_FILE.getId());
    String extent = fileDs.getExtent();
    if (extent != null && !extent.equals("")) {
        String[] imgDimensions = extent.split("x");
        canvas.setHeight(Integer.parseInt(imgDimensions[0]));
        canvas.setWidth(Integer.parseInt(imgDimensions[1]));
    }
    canvas.addIIIFImage(canvasPath, ImageApiProfile.LEVEL_TWO);
    ImageContent thumb = new ImageContent(URIUtil.join(basePath, "services", "api", "thumb", uuid, "large"));
    canvas.addImage(thumb);
    return canvas;
}
Also used : Datastream(edu.unc.lib.boxc.search.api.models.Datastream) ImageContent(de.digitalcollections.iiif.model.ImageContent) Canvas(de.digitalcollections.iiif.model.sharedcanvas.Canvas)

Example 4 with Datastream

use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.

the class DatastreamUtil method getDatastreamUrl.

/**
 * Returns a URL for retrieving a specific datastream of the provided object.
 *
 * @param metadata metadata record for object
 * @param datastreamName name of datastream to return
 * @return url for accessing the datastream.
 */
public static String getDatastreamUrl(ContentObjectRecord metadata, String datastreamName) {
    // Prefer the matching datastream from this object over the same datastream with a different pid prefix
    Datastream preferredDS = getPreferredDatastream(metadata, datastreamName);
    if (preferredDS == null) {
        return "";
    }
    StringBuilder url = new StringBuilder();
    if (!isBlank(preferredDS.getExtension())) {
        if (INDEXABLE_EXTENSIONS.contains(preferredDS.getExtension())) {
            url.append("indexable");
        }
    }
    url.append("content/");
    if (isBlank(preferredDS.getOwner())) {
        url.append(metadata.getId());
    } else {
        url.append(preferredDS.getOwner());
    }
    if (!ORIGINAL_FILE.getId().equals(preferredDS.getName())) {
        url.append("/").append(preferredDS.getName());
    }
    return url.toString();
}
Also used : Datastream(edu.unc.lib.boxc.search.api.models.Datastream)

Example 5 with Datastream

use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.

the class ContentObjectSolrRecord method getDatastreamObject.

@Override
public Datastream getDatastreamObject(String datastreamName) {
    if (datastreamName == null || this.datastreamObjects == null) {
        return null;
    }
    String[] datastreamParts = datastreamName.split("/", 2);
    String pid;
    if (datastreamParts.length > 1) {
        pid = datastreamParts[0];
        if (pid.equals(getId())) {
            pid = null;
        }
        datastreamName = datastreamParts[1];
    } else {
        pid = null;
    }
    for (Datastream datastream : this.datastreamObjects) {
        if (datastream.equals(datastreamName) && (pid == null || pid.equals(datastream.getOwner()))) {
            return datastream;
        }
    }
    return null;
}
Also used : Datastream(edu.unc.lib.boxc.search.api.models.Datastream)

Aggregations

Datastream (edu.unc.lib.boxc.search.api.models.Datastream)20 DatastreamImpl (edu.unc.lib.boxc.search.solr.models.DatastreamImpl)11 Test (org.junit.Test)11 PID (edu.unc.lib.boxc.model.api.ids.PID)2 ContentObject (edu.unc.lib.boxc.model.api.objects.ContentObject)2 FileObject (edu.unc.lib.boxc.model.api.objects.FileObject)2 ImageContent (de.digitalcollections.iiif.model.ImageContent)1 Canvas (de.digitalcollections.iiif.model.sharedcanvas.Canvas)1 Permission (edu.unc.lib.boxc.auth.api.Permission)1 AccessControlService (edu.unc.lib.boxc.auth.api.services.AccessControlService)1 TimerFactory (edu.unc.lib.boxc.common.metrics.TimerFactory)1 SecureXMLFactory.createSAXBuilder (edu.unc.lib.boxc.common.xml.SecureXMLFactory.createSAXBuilder)1 ServiceException (edu.unc.lib.boxc.fcrepo.exceptions.ServiceException)1 DatastreamType (edu.unc.lib.boxc.model.api.DatastreamType)1 NotFoundException (edu.unc.lib.boxc.model.api.exceptions.NotFoundException)1 BinaryObject (edu.unc.lib.boxc.model.api.objects.BinaryObject)1 RepositoryObjectLoader (edu.unc.lib.boxc.model.api.objects.RepositoryObjectLoader)1 WorkObject (edu.unc.lib.boxc.model.api.objects.WorkObject)1 DatastreamPids (edu.unc.lib.boxc.model.fcrepo.ids.DatastreamPids)1 PIDs (edu.unc.lib.boxc.model.fcrepo.ids.PIDs)1