private void findApplication() { SesameSPARQLClient sparqlCl = null; try { sparqlCl = new SesameSPARQLClient(); } catch (RepositoryException e) { logger.error("Init sparql repository error. ", e); return; } oamo = new OAMO(); TupleQueryResult qres = sparqlCl.sparqlToQResult(Queries.getRootOAMOData(lsmFunctionalGraph, oamoID)); Queries.RootOAMOData rootOAMODATA = Queries.parseOAMORootData(qres); oamo.setName(rootOAMODATA.getOamoName()); oamo.setId(rootOAMODATA.getUserID()); oamo.setDescription(rootOAMODATA.getOamoDesc()); oamo.setGraphMeta(rootOAMODATA.getOamoGraphMeta()); qres = sparqlCl.sparqlToQResult(Queries.getOSMOListOfOAMO(lsmFunctionalGraph, oamoID)); ArrayList<Queries.RootOsmoData> OSMODataList = Queries.parseOSMOListOfOAMO(qres); for (Queries.RootOsmoData osmodata : OSMODataList) { GetServiceImpl service = new GetServiceImpl(osmodata.getId()); OSMO osmo = service.getService(); oamo.getOSMO().add(osmo); } }
private void registerService() { User user = new User(); user.setUsername(lsmUserName); user.setPass(lsmPassword); LSMTripleStore lsmStore = new LSMTripleStore(); lsmStore.setUser(user); LSMSchema myOnt = new LSMSchema(OntModelSpec.OWL_DL_MEM); LSMSchema myOntInstance = new LSMSchema(); org.openiot.scheduler.core.utils.lsmpa.entities.User userEnt = new org.openiot.scheduler.core.utils.lsmpa.entities.User( myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); userEnt.setId(osdSpec.getUserID()); // // userEnt.createClassIdv(); for (OAMO oamo : osdSpec.getOAMO()) { logger.debug("OAMO Description: {} ID: {}", oamo.getDescription(), oamo.getId()); logger.debug("OAMO Name: {}", oamo.getName()); org.openiot.scheduler.core.utils.lsmpa.entities.OAMO oamoEnt = new org.openiot.scheduler.core.utils.lsmpa.entities.OAMO( myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); oamoEnt.setId(oamo.getId()); oamoEnt.setName(oamo.getName()); oamoEnt.setUser(userEnt); oamoEnt.setDescription(oamo.getDescription()); oamoEnt.setGraphMeta(oamo.getGraphMeta()); // oamoEnt.createClassIdv(); oamoEnt.createPoamoName(); oamoEnt.createPoamoUserOf(); oamoEnt.createPoamoDescription(); oamoEnt.createPoamoGraphMeta(); userEnt.addService(oamoEnt); // userEnt.createPuserOf(); for (OSMO osmo : oamo.getOSMO()) { logger.debug("OSMO ID: {}", osmo.getId()); logger.debug("OSMO Name: {}", osmo.getName()); logger.debug("OSMO Description: {}", osmo.getDescription()); for (QueryRequest qr : osmo.getQueryRequest()) { logger.debug("qr.getQuery():" + qr.getQuery()); } Service srvcEnt = new Service(myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); srvcEnt.setId(osmo.getId()); srvcEnt.setName(osmo.getName()); srvcEnt.setDescription(osmo.getDescription()); // for (QueryRequest qr : osmo.getQueryRequest()) { Query qstring = new Query(myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); qstring.setqString(qr.getQuery()); // qstring.createClassIdv(); qstring.createPqueryString(); srvcEnt.addQueryString(qstring); } // srvcEnt.createClassIdv(); srvcEnt.createPserviceName(); srvcEnt.createPserviceDescription(); srvcEnt.createPqString(); for (Widget widget : osmo.getRequestPresentation().getWidget()) { WidgetPresentation widgetPre = new WidgetPresentation(myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); widgetPre.setService(srvcEnt); // widgetPre.createClassIdv(); widgetPre.createPwidgetPresOf(); // srvcEnt.addWidgetPresentation(widgetPre); srvcEnt.createPwidgetPres(); logger.debug("widget available id: {}", widget.getWidgetID()); WidgetAvailable wAvail = new WidgetAvailable(myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); wAvail.setId(widget.getWidgetID()); wAvail.setWidgetPre(widgetPre); // / wAvail.createClassIdv(); wAvail.createPWidgetOf(); // widgetPre.setWidgetAvailable(wAvail); widgetPre.createPwidget(); // // for (PresentationAttr pAttr : widget.getPresentationAttr()) { logger.debug("pAttr id: {} --- name: {}", pAttr.getName(), pAttr.getValue()); WidgetAttributes wAttr = new WidgetAttributes(myOnt, myOntInstance, lsmFunctionalGraph, lsmStore); wAttr.setDescription(pAttr.getValue()); wAttr.setName(pAttr.getName()); wAttr.setWidgetPre(widgetPre); // / wAttr.createClassIdv(); wAttr.createPdesc(); wAttr.createPname(); wAttr.createPWidgetAttrOf(); // widgetPre.addWidgetAttr(wAttr); widgetPre.createPwidgetAttr(); } // PresentationAttr } // widget srvcEnt.setOAMO(oamoEnt); // // srvcEnt.createPOAMO(); oamoEnt.addService(srvcEnt); // oamoEnt.createPoamoService(); // } // osmo } // oamo logger.debug(myOntInstance.exportToTriples("TURTLE")); boolean ok = lsmStore.pushRDF(lsmFunctionalGraph, myOntInstance.exportToTriples("N-TRIPLE")); if (ok) { replyMessage = "regester service successfull"; } else { replyMessage = "regester service error"; } logger.debug(replyMessage); }