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 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 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(); } } }