My Project
AbstractObject.h
1 /*-----------------------------------------------------------------------
2 Copyright F2I-CONSULTING, (2014-2016)
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 "EpcDocument.h"
38 
39 namespace resqml2
40 {
41  class DLL_IMPORT_OR_EXPORT AbstractObject
42  {
43  private:
44  gsoap_resqml2_0_1::eml__DataObjectReference* partialObject; // only in case of partial transfer
45 
50  void setUuid(const std::string & uuid);
51 
55  void addOrSetExtraMetadataV2_0_1(const std::string & key, const std::string & value);
56 
60 #if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
61  std::unordered_map< std::string, std::string > getExtraMetadataSetV2_0_1() const;
62 #else
63  std::tr1::unordered_map< std::string, std::string > getExtraMetadataSetV2_0_1() const;
64 #endif
65 
70  std::string getExtraMetadataV2_0_1(const std::string & key);
71 
75  unsigned int getExtraMetadataCountV2_0_1() const;
76 
80  std::string getExtraMetadataKeyAtIndexV2_0_1(const unsigned int & index) const;
81 
85  std::string getExtraMetadataStringValueAtIndexV2_0_1(const unsigned int & index) const;
86 
87  protected:
88 
89  gsoap_resqml2_0_1::eml__AbstractCitedDataObject* gsoapProxy2_0_1;
90 #ifdef WITH_RESQML2_1
91  gsoap_resqml2_1::eml__AbstractObject* gsoapProxy2_1;
92 #endif
93  common::EpcDocument* epcDocument;
94  std::vector<resqml2::Activity*> activitySet;
95 
96  bool updateXml;
97 
101  AbstractObject(common::EpcDocument * epcDoc, gsoap_resqml2_0_1::eml__DataObjectReference* partialObject);
102 
103  AbstractObject(gsoap_resqml2_0_1::eml__AbstractCitedDataObject* proxy = nullptr);
104 
106 
107  void initMandatoryMetadata();
108 
112  virtual void importRelationshipSetFromEpc(common::EpcDocument * epcDoc) = 0;
114 
118  virtual std::vector<epc::Relationship> getAllEpcRelationships() const = 0;
119  friend void common::EpcDocument::serialize(bool useZip64);
120 
121  // Only for Activity. Can not use friendness between AbstractObject and Activity for circular dependencies reason.
122  static void addActivityToResqmlObject(resqml2::Activity* activity, AbstractObject* resqmlObject);
123 
129  void setMetadata(const std::string & guid, const std::string & title, const std::string & editor, const time_t & creation, const std::string & originator,
130  const std::string & description, const time_t & lastUpdate, const std::string & format, const std::string & descriptiveKeywords);
131 
132  public:
133  virtual ~AbstractObject() {}
134 
140  bool isPartial() const {return partialObject != nullptr;}
141 
142  std::string getUuid() const;
143  std::string getTitle() const;
144  std::string getEditor() const;
145  time_t getCreation() const;
146  std::string getOriginator() const;
147  std::string getDescription() const;
148  time_t getLastUpdate() const;
149  std::string getFormat() const;
150  std::string getDescriptiveKeywords() const;
151 
152  void setTitle(const std::string & title);
153  void setEditor(const std::string & editor);
154  void setCreation(const time_t & creation);
155  void setOriginator(const std::string & originator);
156  void setDescription(const std::string & description);
157  void setLastUpdate(const time_t & lastUpdate);
158  void setFormat(const std::string & format);
159  void setDescriptiveKeywords(const std::string & descriptiveKeywords);
160 
165  void setMetadata(const std::string & title, const std::string & editor, const time_t & creation, const std::string & originator,
166  const std::string & description, const time_t & lastUpdate, const std::string & format, const std::string & descriptiveKeywords);
167 
172  void serializeIntoStream(std::ostream * stream);
173 
177  gsoap_resqml2_0_1::eml__AbstractCitedDataObject* getGsoapProxy() const {return gsoapProxy2_0_1;}
178 
182  soap* getGsoapContext() const;
183 
187  int getGsoapType() const;
188 
189  gsoap_resqml2_0_1::eml__DataObjectReference* newResqmlReference() const;
190 
191  gsoap_resqml2_0_1::resqml2__ContactElementReference* newResqmlContactElementReference() const;
192 
196  common::EpcDocument* getEpcDocument() const {return epcDocument;}
197 
201  virtual std::string getXmlNamespace() const;
202 
206  virtual std::string getXmlTag() const = 0;
207 
211  virtual std::string getResqmlVersion() const;
212 
216  std::string getContentType() const;
217 
221  std::string getPartNameInEpcDocument() const;
222 
226  std::string serializeIntoString();
227 
231  void addAlias(const std::string & authority, const std::string & title);
232 
236  unsigned int getAliasCount() const;
237 
241  std::string getAliasAuthorityAtIndex(const unsigned int & index) const;
242 
246  std::string getAliasTitleAtIndex(const unsigned int & index) const;
247 
251  const std::vector<resqml2::Activity*> & getActivitySet() const;
252 
256  void addOrSetExtraMetadata(const std::string & key, const std::string & value);
257 
261 #if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
262  std::unordered_map< std::string, std::string > getExtraMetadataSet() const;
263 #else
264  std::tr1::unordered_map< std::string, std::string > getExtraMetadataSet() const;
265 #endif
266 
271  std::string getExtraMetadata(const std::string & key);
272 
276  unsigned int getExtraMetadataCount() const;
277 
281  std::string getExtraMetadataKeyAtIndex(const unsigned int & index) const;
282 
286  std::string getExtraMetadataStringValueAtIndex(const unsigned int & index) const;
287  };
288 }
void updateAllRelationships()
Definition: EpcDocument.cpp:1241
virtual void serialize(bool useZip64=false)
Definition: EpcDocument.cpp:551
Definition: AbstractObject.h:41
void addGsoapProxy(resqml2::AbstractObject *proxy)
Definition: EpcDocument.cpp:419
Definition: EpcDocument.h:155
Definition: Activity.h:40
bool isPartial() const
Definition: AbstractObject.h:140
common::EpcDocument * getEpcDocument() const
Definition: AbstractObject.h:196
Definition: EpcDocument.h:61
gsoap_resqml2_0_1::eml__AbstractCitedDataObject * getGsoapProxy() const
Definition: AbstractObject.h:177