agentResource.add(ResourceFactory.createResource(foafNamespace + "Agent"));
agentResource.add(ResourceFactory.createResource(foafNamespace + "Person"));
//Resource person = ResourceFactory.createResource(foafNamespace + "Person" );
for(Resource agent : agentResource) {
ResIterator iters = model.listResourcesWithProperty(RDF.type,agent);
if (iters.hasNext()) {
System.out.println("The database contains resource Person for:");
while (iters.hasNext()) {
Resource resource = iters.nextResource();
String resourceName = null;
if(resource.getLocalName() != null) {
resourceName = resource.getLocalName();
} else if(resource.getId() != null) {
if(resource.getId().getLabelString() != null) {
resourceName = resource.getId().getLabelString();
} else {
resourceName = resource.getId().toString();
}
} else if(resource.getURI() != null) {
resourceName = resource.getURI();
}
System.out.println(" " + resourceName+" class:"+resource.getClass());
NodeIterator nodes = model.listObjectsOfProperty(resource, RDF.type);
while(nodes.hasNext()) {
RDFNode node = nodes.nextNode();
if(node.isResource()) {
System.out.println(" type " + node.asResource().getURI());
}
}
StmtIterator stmtI = model.listStatements(resource, null, (RDFNode)null);
while(stmtI.hasNext()) {
Statement statement = stmtI.nextStatement();
if (statement.getPredicate().toString().equals("http://xmlns.com/foaf/0.1/name")){
userName = statement.getObject().toString();
}
System.out.println(" triple "+statement.getPredicate()+" - "+statement.getObject());
}
for(Property property : propertyAccount) {
StmtIterator stmtI1 = model.listStatements(resource, property, (RDFNode)null);
Entity entity = new Entity(userName);
while(stmtI1.hasNext()) {
Statement statement = stmtI1.nextStatement();
System.out.println(" OnlineAccount "+statement.getObject());
String accountURL = "";
String accountUserName = "";
if(statement.getObject().isResource()) {
Resource onlineAccount = statement.getObject().asResource();
NodeIterator nodess = model.listObjectsOfProperty(onlineAccount, RDF.type);
while(nodess.hasNext()) {
RDFNode node = nodess.nextNode();
if(node.isResource()) {
System.out.println(" type " + node.asResource().getURI());
}
}
for(Property property2 : propertyAccountName) {
StmtIterator stmtI2 = model.listStatements(onlineAccount,
property2, (RDFNode)null);
Statement statement2 = stmtI2.nextStatement();
System.out.println(" AccountName "+statement2.getObject());
accountUserName = statement2.getObject().toString();
}
for(Property property2 : propertyAccountProfile) {
StmtIterator stmtI2 = model.listStatements(onlineAccount,
property2, (RDFNode)null);
if(stmtI2.hasNext()){
Statement statement2 = stmtI2.nextStatement();
System.out.println(" AccountProfile "+statement2.getObject());
accountURL = statement2.getObject().toString();
}
}
if(accountUserName.equalsIgnoreCase("not_exist")) {
ReputationWiki.notExistantUser.add(userName);
continue;
}
try{
Double value = Double.parseDouble(accountUserName);
ReputationWiki.userPredefined.add(new Ent_Eva(new Entity(userName),value));
continue;
}catch (Exception e) {}
String domain = ReputationWiki.findDomain(accountURL);
if(domain == null) {
System.out.println("Error: domain is not known from user:"+
entity.getUniqueIdentificator()+" and it is discarted: "+ accountURL);
continue;
}
if(!accountUserName.equals("")){
entity.addIdentificatorInCommunities(GlobalModel.getCommunities().get(domain),
new EntityIdentifier(accountUserName,null));
}
else{
entity.addIdentificatorInCommunities(GlobalModel.getCommunities().get(domain),
new EntityIdentifier(entity.getUniqueIdentificator(),accountURL));
}
if(!entity.getIdentificatorInCommunities().isEmpty()) {
GlobalModel.addEntity(entity);
}
}
}
}
}
}
}
ResIterator iters = model.listSubjectsWithProperty(RDF.type,foafNamespace+"Person");
if (iters.hasNext()) {
System.out.println("The database contains literal person for:");
while (iters.hasNext()) {
Resource resource = iters.nextResource();
System.out.println(" " + resource.getLocalName());
// node.
}
} else {
System.out.println("No simple String foafNamespace+Person were found in the database");
}
Property propertyOnlineAccount = ResourceFactory.createProperty(
foafNamespace, "OnlineAccount");
iters = model.listSubjectsWithProperty(propertyOnlineAccount);
if (iters.hasNext()) {
System.out.println("The database contains OnlineAccount for:");
while (iters.hasNext()) {
Resource resource = iters.nextResource();
System.out.println(" " + resource.getLocalName());
}
} else {
System.out.println("No PROPERTY OnlineAccount were found in the database");
}
iters = model.listSubjectsWithProperty(RDF.type);
if (iters.hasNext()) {
System.out.println("The database contains RDF.type for:");
while (iters.hasNext()) {
Resource resource = iters.nextResource();
NodeIterator nodes = model.listObjectsOfProperty(resource, RDF.type);
String resourceName = null;
if(resource.getLocalName() != null) {
resourceName = resource.getLocalName();
} else if(resource.getId() != null) {