Search in sources :

Example 1 with Description

use of nl.knaw.huygens.timbuctoo.remote.rs.discover.Description in project timbuctoo by HuygensING.

the class ResultView method init.

private void init(Result<?> result, Interpreter interpreter) {
    uri = result.getUri().toString();
    ordinal = result.getOrdinal();
    statusCode = result.getStatusCode();
    contentType = result.getContent().map(o -> o.getClass().getSimpleName()).orElse("(no content)");
    Object content = result.getContent().orElse(null);
    if (content != null) {
        if (content instanceof LinkList) {
            LinkList linkList = (LinkList) content;
            childCount = linkList.getValidUris().size();
        } else if (content instanceof RsRoot) {
            RsRoot<?, ?> rsRoot = (RsRoot) content;
            childCount = rsRoot.getItemList().size();
            Optional<Capability> optionalCapa = rsRoot.getCapability();
            if (optionalCapa.isPresent()) {
                capability = optionalCapa.get().xmlValue;
            }
        } else if (content instanceof Description) {
            description = new DescriptionView((Result<Description>) result, interpreter);
        }
    }
    if (result.getDescriptionResult().isPresent()) {
        describedBy = new ResultView(result.getDescriptionResult().get(), interpreter);
    }
    errorList = result.getErrors().stream().map(throwable -> new ErrorView(throwable, interpreter)).collect(Collectors.toList());
    invalidUris = result.getInvalidUris();
}
Also used : Description(nl.knaw.huygens.timbuctoo.remote.rs.discover.Description) Optional(java.util.Optional) RsRoot(nl.knaw.huygens.timbuctoo.remote.rs.xml.RsRoot) LinkList(nl.knaw.huygens.timbuctoo.remote.rs.discover.LinkList) Result(nl.knaw.huygens.timbuctoo.remote.rs.discover.Result)

Example 2 with Description

use of nl.knaw.huygens.timbuctoo.remote.rs.discover.Description in project timbuctoo by HuygensING.

the class DescriptionView method init.

private void init(Result<Description> descriptionResult, Interpreter interpreter) {
    if (descriptionResult.getContent().isPresent()) {
        Description description = descriptionResult.getContent().get();
        String mimeType = description.getDescribedByLink().getType().orElse(null);
        Optional<RDFFormat> maybeFormat = Rio.getParserFormatForMIMEType(mimeType);
        if (!maybeFormat.isPresent()) {
            String filename = descriptionResult.getUri().toString();
            maybeFormat = Rio.getParserFormatForFileName(filename);
        }
        if (maybeFormat.isPresent()) {
            createDescriptionNode(description, maybeFormat.get(), interpreter);
        } else {
            rawContent = description.getRawContent();
        }
    }
}
Also used : Description(nl.knaw.huygens.timbuctoo.remote.rs.discover.Description) RDFFormat(org.eclipse.rdf4j.rio.RDFFormat)

Aggregations

Description (nl.knaw.huygens.timbuctoo.remote.rs.discover.Description)2 Optional (java.util.Optional)1 LinkList (nl.knaw.huygens.timbuctoo.remote.rs.discover.LinkList)1 Result (nl.knaw.huygens.timbuctoo.remote.rs.discover.Result)1 RsRoot (nl.knaw.huygens.timbuctoo.remote.rs.xml.RsRoot)1 RDFFormat (org.eclipse.rdf4j.rio.RDFFormat)1