My Project
AbstractObject.h
1 /*-----------------------------------------------------------------------
2 Copyright F2I-CONSULTING, (2014-2017)
3 
4 philippe.verney@f2i-consulting.com
5 
6 This software is a computer program whose purpose is to access to data formatted using Energistics standards.
7 
8 This software is governed by the CeCILL-B license under French law and
9 abiding by the rules of distribution of free software. You can use,
10 modify and/ or redistribute the software under the terms of the CeCILL-B
11 license as circulated by CEA, CNRS and INRIA at the following URL
12 "http://www.cecill.info".
13 
14 As a counterpart to the access to the source code and rights to copy,
15 modify and redistribute granted by the license, users are provided only
16 with a limited warranty and the software's author, the holder of the
17 economic rights, and the successive licensors have only limited
18 liability.
19 
20 In this respect, the user's attention is drawn to the risks associated
21 with loading, using, modifying and/or developing or reproducing the
22 software by the user in light of its specific status of free software,
23 that may mean that it is complicated to manipulate, and that also
24 therefore means that it is reserved for developers and experienced
25 professionals having in-depth computer knowledge. Users are therefore
26 encouraged to load and test the software's suitability as regards their
27 requirements in conditions enabling the security of their systems and/or
28 data to be ensured and, more generally, to use and operate it in the
29 same conditions as regards security.
30 
31 The fact that you are presently reading this means that you have had
32 knowledge of the CeCILL-B license and that you accept its terms.
33 -----------------------------------------------------------------------*/
34 #pragma once
35 
36 #include "proxies/gsoap_resqml2_0_1H.h"
37 #include "proxies/gsoap_eml2_1H.h"
38 #include "common/EpcDocument.h"
39 
40 namespace common
41 {
42  class DLL_IMPORT_OR_EXPORT AbstractObject
43  {
44  private:
45  gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject; // only in case of partial transfer
46 
51  void setUuid(const std::string & uuid);
52 
56  void pushBackExtraMetadataV2_0_1(const std::string & key, const std::string & value);
57 
61 #if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
62  std::unordered_map< std::string, std::string > getExtraMetadataSetV2_0_1() const;
63 #else
64  std::tr1::unordered_map< std::string, std::string > getExtraMetadataSetV2_0_1() const;
65 #endif
66 
71  std::vector<std::string> getExtraMetadataV2_0_1(const std::string & key) const;
72 
76  unsigned int getExtraMetadataCountV2_0_1() const;
77 
81  std::string getExtraMetadataKeyAtIndexV2_0_1(const unsigned int & index) const;
82 
86  std::string getExtraMetadataStringValueAtIndexV2_0_1(const unsigned int & index) const;
87 
88  protected:
89 
90  enum EmlVersion {
91  TWO_DOT_ZERO = 0,
92  TWO_DOT_ONE = 1,
93  };
94 
95  gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* gsoapProxy2_0_1;
96  gsoap_eml2_1::eml21__AbstractObject* gsoapProxy2_1;
97  common::EpcDocument* epcDocument;
98  std::vector<resqml2::Activity*> activitySet;
99 
100  bool updateXml;
101 
102  //Default constructor
103  AbstractObject();
104 
108  AbstractObject(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject);
109 
110  AbstractObject(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* proxy);
111 
112  AbstractObject(gsoap_eml2_1::eml21__AbstractObject* proxy);
113 
115 
116  void initMandatoryMetadata();
117 
121  virtual void importRelationshipSetFromEpc(common::EpcDocument * epcDoc) = 0;
123 
127  virtual std::vector<epc::Relationship> getAllEpcRelationships() const = 0;
128  friend void common::EpcDocument::serialize(bool useZip64);
129 
130  // Only for Activity. Can not use friendness between AbstractObject and Activity for circular dependencies reason.
131  static void addActivityToResqmlObject(resqml2::Activity* activity, AbstractObject* resqmlObject);
132 
138  void setMetadata(const std::string & guid, const std::string & title, const std::string & editor, const time_t & creation, const std::string & originator,
139  const std::string & description, const time_t & lastUpdate, const std::string & format, const std::string & descriptiveKeywords);
140 
144  void cannotBePartial() const;
145 
149  void changeToPartialObject();
150 
151  public:
152  virtual ~AbstractObject() {}
153 
159  bool isPartial() const {return partialObject != nullptr;}
160 
161  std::string getUuid() const;
162  std::string getTitle() const;
163  std::string getEditor() const;
164  time_t getCreation() const;
165  std::string getOriginator() const;
166  std::string getDescription() const;
167  time_t getLastUpdate() const;
168  std::string getFormat() const;
169  std::string getDescriptiveKeywords() const;
170 
171  void setTitle(const std::string & title);
172  void setEditor(const std::string & editor);
173  void setCreation(const time_t & creation);
174  void setOriginator(const std::string & originator);
175  void setDescription(const std::string & description);
176  void setLastUpdate(const time_t & lastUpdate);
177  void setFormat(const std::string & format);
178  void setDescriptiveKeywords(const std::string & descriptiveKeywords);
179 
184  void setMetadata(const std::string & title, const std::string & editor, const time_t & creation, const std::string & originator,
185  const std::string & description, const time_t & lastUpdate, const std::string & format, const std::string & descriptiveKeywords);
186 
191  void serializeIntoStream(std::ostream * stream);
192 
196  gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* getGsoapProxy() const {return gsoapProxy2_0_1;}
197 
201  soap* getGsoapContext() const;
202 
206  int getGsoapType() const;
207 
208  gsoap_resqml2_0_1::eml20__DataObjectReference* newResqmlReference() const;
209  gsoap_eml2_1::eml21__DataObjectReference* newEmlReference() const;
210 
211  gsoap_resqml2_0_1::resqml2__ContactElementReference* newResqmlContactElementReference() const;
212 
216  common::EpcDocument* getEpcDocument() const {return epcDocument;}
217 
221  virtual std::string getXmlNamespace() const;
222 
226  virtual std::string getXmlTag() const = 0;
227 
231  virtual std::string getResqmlVersion() const;
232 
236  virtual std::string getContentType() const;
237 
241  virtual std::string getPartNameInEpcDocument() const;
242 
246  std::string serializeIntoString();
247 
251  void addAlias(const std::string & authority, const std::string & title);
252 
256  unsigned int getAliasCount() const;
257 
261  std::string getAliasAuthorityAtIndex(const unsigned int & index) const;
262 
266  std::string getAliasTitleAtIndex(const unsigned int & index) const;
267 
271  const std::vector<resqml2::Activity*> & getActivitySet() const;
272 
276  unsigned int getActivityCount() const;
277 
281  resqml2::Activity* getActivity (const unsigned int & index) const;
282 
286  void pushBackExtraMetadata(const std::string & key, const std::string & value);
287 
291 #if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
292  std::unordered_map< std::string, std::string > getExtraMetadataSet() const;
293 #else
294  std::tr1::unordered_map< std::string, std::string > getExtraMetadataSet() const;
295 #endif
296 
301  std::vector<std::string> getExtraMetadata(const std::string & key) const;
302 
306  unsigned int getExtraMetadataCount() const;
307 
311  std::string getExtraMetadataKeyAtIndex(const unsigned int & index) const;
312 
316  std::string getExtraMetadataStringValueAtIndex(const unsigned int & index) const;
317  };
318 }
void updateAllRelationships()
Definition: EpcDocument.cpp:1466
bool isPartial() const
Definition: AbstractObject.h:159
virtual void serialize(bool useZip64=false)
Definition: EpcDocument.cpp:652
common::EpcDocument * getEpcDocument() const
Definition: AbstractObject.h:216
Definition: EpcDocument.h:168
Definition: AbstractObject.h:42
Definition: AbstractHdfProxy.h:43
Definition: Activity.h:40
void addGsoapProxy(common::AbstractObject *proxy)
Definition: EpcDocument.cpp:519
gsoap_resqml2_0_1::eml20__AbstractCitedDataObject * getGsoapProxy() const
Definition: AbstractObject.h:196