Package org.openrdf.model.impl

Examples of org.openrdf.model.impl.TreeModel


        CacheEntry entry =  backend.getEntry(resource);

        if(entry != null) {
            return entry.getTriples();
        } else {
            return new TreeModel();
        }
    }
View Full Code Here


        String account = java.net.URI.create(resource.replaceAll(" ", "%20")).getPath().substring(1);
        String prefix = getEndpointSuffix(endpoint);
        try {
            final LdapConnection ldap = openLdapConnection(endpoint);

            Model model = new TreeModel();
            ValueFactory vf = ValueFactoryImpl.getInstance();
            String userDN = buildDN(prefix, account, ldap);

            Map<String, java.util.List<String>> accountData = getAccountData(userDN, ldap);

            final URI subject = vf.createURI(resource);
            for (String attr : MAPPING.keySet()) {
                if (!accountData.containsKey(attr)) {
                    continue;
                }

                final PredicateObjectFactory factory = MAPPING.get(attr);
                final URI predicate = factory.createPredicate(vf);

                for (String val : accountData.get(attr)) {
                    for (Value object : factory.createObjects(val, vf)) {
                        model.add(vf.createStatement(subject, predicate, object));
                    }
                }

            }
View Full Code Here

            // read triples for this entry from cache repository
            RepositoryConnection con = cacheRepository.getConnection();
            try {
                con.begin();

                Model triples = new TreeModel();
                ModelCommons.add(triples, con.getStatements(resource,null,null,true));
                ce.setTriples(triples);

                con.commit();
            } catch(RepositoryException ex) {
View Full Code Here

        this.httpStatus = httpStatus;

        try {
        this.data = ModelCommons.asModel(triples);
        } catch (RepositoryException e) {
            this.data = new TreeModel();
        }
    }
View Full Code Here

        public ResponseHandler(String resource, Endpoint endpoint) throws RepositoryException {
            this.resource = resource;
            this.endpoint = endpoint;

            triples = new TreeModel();
        }
View Full Code Here

  @Override
  public ClientResponse retrieveResource(String resource, LDClientService client, Endpoint endpoint) throws DataRetrievalException {
        String filename = resource.substring("http://localhost/".length()) + ".ttl";

        Model triples = new TreeModel();
        try {
            ModelCommons.add(triples, DummyProvider.class.getResourceAsStream(filename), resource, RDFFormat.TURTLE);

        } catch (RDFParseException e) {
            throw new DataRetrievalException("could not parse resource data for file "+filename);
View Full Code Here

     * @param repository
     * @return
     * @throws RepositoryException
     */
    public static Model asModel(Repository repository, Predicate<Statement>... filters) throws RepositoryException {
        Model model = new TreeModel();

        RepositoryConnection con = repository.getConnection();
        try {
            con.begin();

View Full Code Here

    }

    @Override
    public ClientResponse retrieveResource(String resource, LDClientService client, Endpoint endpoint) throws DataRetrievalException {

        Model model = new TreeModel();

        String uri = resource;
        URI objUri;
        try {
            objUri = new URI(uri);
        } catch (URISyntaxException e) {
            throw new RuntimeException("URI '" + uri + "'could not be parsed, it is not a valid URI");
        }

        String video_id = null;
        if (uri.startsWith(YOUTUBE_V)) { // YouTube short watch video URL
            String[] p_components = objUri.getPath().split("/");
            video_id = p_components[p_components.length - 1];
        } else if (resource.startsWith(YOUTUBE_WATCH)) { // YouTube watch video URL
            List<NameValuePair> params = URLEncodedUtils.parse(objUri, "UTF-8");
            for (NameValuePair pair : params) {
                if ("v".equals(pair.getName())) {
                    video_id = pair.getValue();
                    break;
                }
            }
        } else if (uri.startsWith(YOUTUBE_GDATA)) { // GData URI
            video_id = StringUtils.removeStart(uri, YOUTUBE_GDATA);
        }
        if (StringUtils.isBlank(video_id)) {
            String msg = "Not valid video id found in '" + uri + "'";
            log.error(msg);
            throw new DataRetrievalException(msg);
        } else {
            model.add(new URIImpl(uri), new URIImpl(FOAF_PRIMARY_TOPIC), new URIImpl(YoutubeVideoProvider.YOUTUBE_BASE_URI + video_id), (Resource)null);
            // FIXME: add inverse triple, but maybe at the YoutubeVideoProvider

            ClientResponse clientResponse = new ClientResponse(200, model);
            clientResponse.setExpires(DateUtils.addYears(new Date(), 10));
            return clientResponse;
View Full Code Here

TOP

Related Classes of org.openrdf.model.impl.TreeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.