MICO Platform
 All Classes Namespaces Functions Variables Friends
PersistenceService.hpp
1 #ifndef HAVE_PERSISTENCE_SERVICE_H
2 #define HAVE_PERSISTENCE_SERVICE_H 1
3 
4 #include <string>
5 #include <iterator>
6 #include <memory>
7 
8 #include <boost/iterator/iterator_facade.hpp>
9 
10 
11 #include "Metadata.hpp"
12 //#include "ContentItem.hpp"
13 #include "anno4cpp.h"
14 #include "Uri.hpp"
15 
16 //#include "rdf_model.hpp"
17 //#include "rdf_query.hpp"
18 
19 
20 
21 namespace mico {
22  namespace persistence {
23 
24  using namespace mico::rdf::query;
25 
26  class item_iterator;
27 
28  namespace model {
29  class Item;
30  }
31 
32 
37  class PersistenceMetadata : public Metadata {
38  friend class PersistenceService;
39 
40  protected:
41  PersistenceMetadata(std::string baseUrl) : Metadata(baseUrl) {};
42 
43  };
44 
45 
52 
53  private:
54 
55  std::string marmottaServerUrl;
56  std::string contentDirectory;
57  PersistenceMetadata metadata;
58  std::string m_jniErrorMessage;
59 
60  static JNIEnv* m_sEnv;
61 
62  jnipp::GlobalRef<ComGithubAnno4jAnno4j> m_anno4j;
63 
64 
66  void initService();
67 
68  void setContext(jnipp::Ref<OrgOpenrdfRepositoryObjectObjectConnection> con, jnipp::Ref<OrgOpenrdfModelURI> context);
69 
70 
71  public:
72  static JavaVM* m_sJvm;
73 
74 
75  static JavaVM* getJVM() { return m_sJvm; }
76 
82  PersistenceService(std::string serverAddress);
83 
84 
90  PersistenceService(std::string serverAddress, int marmottaPort, std::string user, std::string password);
91 
92 
99  PersistenceService(std::string marmottaServerUrl, std::string contentDirectory);
100 
101 
108  PersistenceMetadata& getMetadata() { return metadata; };
109 
116  std::shared_ptr<model::Item> createItem();
117 
124  std::shared_ptr<model::Item> getItem(const mico::persistence::model::URI& id);
125 
129  void deleteItem(const mico::persistence::model::URI& id);
130 
131 
139  std::vector<std::shared_ptr<model::Item> > getItems();
140 
141 // /**
142 // * Return an iterator over all currently available content items.
143 // *
144 // * @return iterable
145 // */
146 // item_iterator begin();
147 
148 
149 // /**
150 // * Return the end iterator for checking when iteration has completed.
151 // */
152 // item_iterator end();
153 
154 
155  jnipp::LocalRef<jnipp::com::github::anno4j::Anno4j> getAnno4j();
156 
157  std::string getStoragePrefix();
158 
159  std::string getContentDirectory();
160 
161  std::string unmaskContentLocation(const std::string &maskedURL );
162 
163  void checkJavaExceptionThrow();
164 
165  void checkJavaExceptionThrow(std::vector<std::string> exceptionNames);
166 
167  bool checkJavaExceptionNoThrow(std::string& msg);
168 
169  bool checkJavaExceptionNoThrow(std::vector<std::string> exceptionNames, std::string& msg);
170  };
171 
172 
173 #ifndef DOXYGEN_SHOULD_SKIP_THIS
174 
177 // class item_iterator : public boost::iterator_facade<item_iterator, Item*, boost::forward_traversal_tag, Item*> {
178 // private:
179 // int pos;
180 // const std::string& baseUrl;
181 // const std::string& contentDirectory;
182 // const mico::rdf::query::TupleResult* result;
183 
184 // public:
185 // item_iterator(const std::string& baseUrl, const std::string& contentDirectory)
186 // : pos(-1), baseUrl(baseUrl), contentDirectory(contentDirectory), result(NULL) {};
187 
188 // item_iterator(const std::string& baseUrl, const std::string& contentDirectory, const mico::rdf::query::TupleResult* r)
189 // : pos(0), baseUrl(baseUrl), contentDirectory(contentDirectory), result(r) {};
190 
191 // ~item_iterator() { if(result) { delete result; } };
192 
193 
194 // private:
195 
196 // friend class boost::iterator_core_access;
197 
198 // void increment();
199 // bool equal(item_iterator const& other) const;
200 // Item* dereference() const;
201 
202 // };
203 #endif
204  }
205 }
206 
207 #endif
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...
Definition: http_client.cpp:23
Main service for accessing the MICO persistence API.
Definition: PersistenceService.hpp:51
PersistenceMetadata & getMetadata()
Get a handle on the overall metadata storage of the persistence service.
Definition: PersistenceService.hpp:108
A class offering access to RDF metadata through SPARQL.
Definition: Metadata.hpp:28
Specialised support for persistence service metadata.
Definition: PersistenceService.hpp:37
Definition: rdf_query.hpp:17
A URI.
Definition: Uri.hpp:22