Search in sources :

Example 1 with LinkList

use of nl.knaw.huygens.timbuctoo.remote.rs.discover.LinkList 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)

Aggregations

Optional (java.util.Optional)1 Description (nl.knaw.huygens.timbuctoo.remote.rs.discover.Description)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