#!/bin/bash
-/opt/Qt5.11/5.11.0/gcc_64/bin/qmake smartapi.pro -o Makefile.lib && \
-/opt/Qt5.11/5.11.0/gcc_64/bin/qmake smartapitests.pro -o Makefile.objecttests && \
-/opt/Qt5.11/5.11.0/gcc_64/bin/qmake smartapitests.pro -o Makefile.agenttests && \
-/opt/Qt5.11/5.11.0/gcc_64/bin/qmake smartapigraphtests.pro -o Makefile.graphtests && \
-/opt/Qt5.11/5.11.0/gcc_64/bin/qmake smartapiplugintests.pro -o Makefile.plugintests && \
-/opt/Qt5.11/5.11.0/gcc_64/bin/qmake smartapiplugin.pro -o Makefile.plugin && \
+/opt/Qt5.11/5.12.2/gcc_64/bin/qmake smartapi.pro -o Makefile.lib && \
+/opt/Qt5.11/5.12.2/gcc_64/bin/qmake smartapitests.pro -o Makefile.objecttests && \
+/opt/Qt5.11/5.12.2/gcc_64/bin/qmake smartapitests.pro -o Makefile.agenttests && \
+/opt/Qt5.11/5.12.2/gcc_64/bin/qmake smartapigraphtests.pro -o Makefile.graphtests && \
+/opt/Qt5.11/5.12.2/gcc_64/bin/qmake smartapiplugintests.pro -o Makefile.plugintests && \
+/opt/Qt5.11/5.12.2/gcc_64/bin/qmake smartapiplugin.pro -o Makefile.plugin && \
\
make -f Makefile.lib -j 3 && \
make -f Makefile.objecttests -j 2 && \
}
return isDependent;
}
+
+bool PriceListSpecification::hasPriceSpecification(QString identifier)
+{
+ for (PropertyListItem<PriceSpecification*>* i = mPriceSpecifications.firstItem(); i != NULL; i = i->next()) {
+ if (i->getItem() &&i->getItem()->getIdentifierUri() == identifier)
+ return true;
+ }
+ return false;
+}
+
+
virtual void clearReferences(QSet<GraphItem*>* trash);
bool hasPriceSpecification() { return (mPriceSpecifications.length() > 0); }
+ bool hasPriceSpecification(QString identifier);
void addPriceSpecification(PriceSpecification* priceSpecification) { mPriceSpecifications.append(priceSpecification); }
PropertyList<PriceSpecification*> getPriceSpecifications() { return mPriceSpecifications; }
public:
Literal(QVariant v, QString d) : RDFNode(NodeType::NodeLiteral) {
value = v;
- dataType = QUrl(d);
+ dataType = QUrl(d);
}
QString getValue() { return value.toString(); }
#include <QJsonDocument>
#include <QJsonObject>
#include <QElapsedTimer>
+#include <QRegularExpression>
#include <openssl/rand.h>
#include <unistd.h>
import smartapi.model.Grading;
import smartapi.model.Obj;
-public class ConceptValidator {
-
+public class ConceptValidator
+{
private static HashMap<String, ConceptDetails> concepts = new HashMap<String, ConceptDetails>();
static
}
try {
InputStream in = null;
+
// for jar package and eclipse
try {
in = new FileInputStream((new File(OntologyAgent.ontologyFolderPath + prefix + ".ttl")));
} catch ( FileNotFoundException e ) {
// nothing to do, because probably running with Maven
}
+
// for maven
if (in == null) {
in = FileManager.get().open(prefix + ".ttl");
}
+
if ( !handleOntology(prefix, in, SERIALIZATION.TURTLE) ) {
System.err.println("Failed to load " + prefix + " ontology from " + OntologyAgent.ontologyFolderPath + prefix + ".ttl");
}
Property commentProp = model.createProperty(PROPERTY.getUri(PROPERTY.COMMENT));
// iterate over subjects in model
ResIterator i = model.listSubjects();
+
while ( i.hasNext() ) {
Resource resource = i.next();
// if resource has uri
System.err.println("Unable to parse MQTT message.");
e.printStackTrace();
return null;
- }
+ }
}
return Tools.parseMessage(clazz, body, contentType);
}
String myIdentity;
- String myIdentityPrefix = "http://seas.asema.com/registrationservertest/";
-
- //String registrationUri = "http://seas.asema.com/webapps/rs/v1.0e1.0/register";
+ String myIdentityPrefix = "http://www.smart-api.io/registrationservertest/";
String registrationUri = "http://development.asema.com:8080/app-core/smartapi/v1.0e1.0/access";
-
- //String searchUri = "http://seas.asema.com/webapps/rs/v1.0e1.0/search";
String rsSearchUri = "http://development.asema.com:8080/app-core/smartapi/v1.0e1.0/access";
public TestRegistrationServer()
s.setName("Registration Server Test Service");
Activity a = new Activity();
s.addCapability(a);
- s.setCoordinates(60.180824, 24.832116);
+ s.setCoordinates(62.180824, 21.832116);
agent.debugMode(true);
Response r = agent.registrate(s);
if ( r == null || r.hasErrors() ) {
import smartapi.factory.Factory;
import smartapi.model.*;
-public class testOrientdb {
+public class TestRegistrations {
public static void regst5()
{
from rdflib import Graph, URIRef
concepts = {}
-def initConcepts():
+
+def initConcepts():
ontUpdated = OntologyAgent.updateOntologies()
if ontUpdated or len(concepts)==0:
# format = None
# else:
# format = 'xml'
- g = Graph()
+ g = Graph()
g.parse(ontFile, format = 'turtle')
subs = g.subjects()
for s in subs:
if isinstance(s, URIRef):
label = g.label(s)
comment = g.comment(s)
- concepts[str(s)] = (label, comment)
+ concepts[str(s)] = (label, comment)
print 'ConceptValidator has been initialized. It has ', len(concepts), ' concepts.'
class ConceptValidator(object):
initConcepts() # only execute once. It generates information needed by explain()
-
+
@classmethod
def validate(cls, obj):
'''
from sets import Set
initConcepts() # in case update is needed, for example when suddenly ontology has been updated in backend server.
-
+
grading = Grading()
# get rdf model out of this SmartAPI Obj
# subject has to have rdf:Type statement, to define its type
subs = graph.subjects()
subjectSet = Set()
+
for sub in subs:
subjectSet.add(sub)
+
for sub in subjectSet:
if not (sub, URIRef(PROPERTY.RDF_TYPE), None) in graph:
e = Error()
e.addType(RESOURCE.UNDEFINEDCONCEPTERROR)
- e.setDescription("Found subject is not defined by rdf:Type statement (" + str(sub) + ").")
+ e.setDescription("Found subject is not defined by rdf:Type statement (" + str(sub) + ").")
grading.addError(e)
- conceptErrorCount = conceptErrorCount+1
+ conceptErrorCount = conceptErrorCount+1
- # validate all triples, check whether they have been defined in ontology
+ # validate all triples, check whether they have been defined in ontology
for s, p, o in graph:
numberOfTestedTriples = numberOfTestedTriples+1
# undefined property
e = Error()
e.addType(RESOURCE.UNDEFINEDCONCEPTERROR)
- e.setDescription("Found property is not defined in any of the inspected ontologies (" + str(p) + ").")
+ e.setDescription("Found property is not defined in any of the inspected ontologies (" + str(p) + ").")
grading.addError(e)
- conceptErrorCount = conceptErrorCount+1
+ conceptErrorCount = conceptErrorCount+1
# some property's object has to be URIRef, and defined in ontology
if str(p) in [PROPERTY.RDF_TYPE, PROPERTY.METHOD, PROPERTY.QUANTITYKIND, PROPERTY.UNIT, PROPERTY.CATEGORY,
# object is wrong data type
e = Error()
e.addType(RESOURCE.ILLEGALVALUEERROR)
- e.setDescription("Value of " + str(p) + " should be a URI resource, found " + str(o) + ".")
+ e.setDescription("Value of " + str(p) + " should be a URI resource, found " + str(o) + ".")
grading.addError(e)
valueErrorCount = valueErrorCount+1
else:
if ( conceptErrorCount > 0 ):
# calculate concept grade from 0 to 10
conceptGrade = (1 - conceptErrorCount/numberOfTestedTriples) * 10.0
-
+
grading.setValueGrade(valueGrade)
- grading.setConceptGrade(conceptGrade)
+ grading.setConceptGrade(conceptGrade)
grading.setGrade((valueGrade+conceptGrade)/2.0)
return grading
System.out.println(Tools.toString(coffeeMakerFor10Cups));
}
-
}
response_activity.addEntity(resp_entity)
else:
pass
-
+
return response_activity
rdfs:isDefinedBy smartapi:DataOntology ;
rdfs:subClassOf smartapi:TemporalEntity;
vs:term_status "testing".
-
+
smartapi:instant a owl:DatatypeProperty ;
rdfs:label "Instant"@en ;
rdfs:comment "A timestamp of the data."@en ;