public void setCredentail(ICognitiveAgent agent, ICredential credential) { INamedIndividual agentInd = findIndividualByUri(agent.getUri()); if (agentInd == null) { agent.storeCognitiveAgent(); agentInd = findIndividualByUri(agent.getUri()); } INamedIndividual credentialInd = findIndividualByUri(credential.getUri()); if (credentialInd == null) { credential.storeCredential(); credentialInd = findIndividualByUri(credential.getUri()); } IOntology onto = getAdaptationOntology(); if (onto instanceof SesameOntology) { ValueFactory factory = ((SesameOntology) onto).getRepository().getValueFactory(); URI subject = factory.createURI(agentInd.getUri()); URI predicate = factory.createURI(getEntityUri(HAS_CREDENTIAL)); URI object = factory.createURI(credentialInd.getUri()); try { RepositoryConnection con = ((SesameOntology) onto).getRepository().getConnection(); try { con.add(subject, predicate, object); } finally { con.close(); } } catch (RepositoryException e) { e.printStackTrace(); } } }
public void setApplicationInteraction( ICognitiveAgent agent, IApplicationInteraction interaction) { INamedIndividual agentInd = findIndividualByUri(agent.getUri()); if (agentInd == null) { agent.storeCognitiveAgent(); agentInd = findIndividualByUri(agent.getUri()); } INamedIndividual interactionInd = findIndividualByUri(interaction.getUri()); if (interactionInd == null) { interaction.storeApplicationInteraction(); interactionInd = findIndividualByUri(interaction.getUri()); } IOntology onto = getAdaptationOntology(); if (onto instanceof SesameOntology) { ValueFactory factory = ((SesameOntology) onto).getRepository().getValueFactory(); URI subject = factory.createURI(agentInd.getUri()); URI predicate = factory.createURI(getEntityUri(INVOLVED_IN)); URI object = factory.createURI(interactionInd.getUri()); try { RepositoryConnection con = ((SesameOntology) onto).getRepository().getConnection(); try { con.add(subject, predicate, object); } finally { con.close(); } } catch (RepositoryException e) { e.printStackTrace(); } } }
public void setInterestingEntity(ICognitiveAgent agent, IEntity entity) { INamedIndividual agentInd = findIndividualByUri(agent.getUri()); if (agentInd == null) { agent.storeCognitiveAgent(); agentInd = findIndividualByUri(agent.getUri()); } INamedIndividual entityInd = findIndividualByUri(entity.getUri()); if (entityInd == null) { entity.storeEntity(); entityInd = findIndividualByUri(entity.getUri()); } IOntology onto = getAdaptationOntology(); if (onto instanceof SesameOntology) { ValueFactory factory = ((SesameOntology) onto).getRepository().getValueFactory(); URI subject = factory.createURI(agentInd.getUri()); URI predicate = factory.createURI(getEntityUri(HAS_INTEREST)); URI object = factory.createURI(entityInd.getUri()); try { RepositoryConnection con = ((SesameOntology) onto).getRepository().getConnection(); try { con.add(subject, predicate, object); } finally { con.close(); } } catch (RepositoryException e) { e.printStackTrace(); } } }
public Set<IResource> getRecommendation(ICognitiveAgent agent) { INamedIndividual agentInd = findIndividualByUri(agent.getUri()); Set<IPropertyMember> props = findPropertyMemberBySourceIndividual(agentInd); Set<IResource> ress = new HashSet<IResource>(); ; for (IPropertyMember prop : props) { if (prop.getProperty().getUri().equals(getEntityUri(IS_RECOMMENDED))) { INamedIndividual ind = (INamedIndividual) prop.getTarget(); if (ind.getTypes().contains(findConceptByUri(getEntityUri("Content")))) ress.add(new Resource(ind.getUri(), 0)); else if (ind.getTypes().contains(findConceptByUri(getEntityUri("Content_Bearing_Object")))) ress.add(new Resource(ind.getUri(), 1)); } } return ress; }