Fesapi  0.13.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
AbstractObject.h
1 /*-----------------------------------------------------------------------
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"; you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under the License.
18 -----------------------------------------------------------------------*/
19 #pragma once
20 
21 #include "proxies/gsoap_resqml2_0_1H.h"
22 #include "proxies/gsoap_eml2_1H.h"
23 #include "common/EpcDocument.h"
24 
25 namespace COMMON_NS
26 {
27  class DLL_IMPORT_OR_EXPORT AbstractObject
28  {
29  private:
30  gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject; // only in case of partial transfer
31 
36  void setUuid(const std::string & uuid);
37 
41  void pushBackExtraMetadataV2_0_1(const std::string & key, const std::string & value);
42 
46 #if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
47  std::unordered_map< std::string, std::string > getExtraMetadataSetV2_0_1() const;
48 #else
49  std::tr1::unordered_map< std::string, std::string > getExtraMetadataSetV2_0_1() const;
50 #endif
51 
56  std::vector<std::string> getExtraMetadataV2_0_1(const std::string & key) const;
57 
61  unsigned int getExtraMetadataCountV2_0_1() const;
62 
66  std::string getExtraMetadataKeyAtIndexV2_0_1(const unsigned int & index) const;
67 
71  std::string getExtraMetadataStringValueAtIndexV2_0_1(const unsigned int & index) const;
72 
73  protected:
74 
75  enum EmlVersion {
76  TWO_DOT_ZERO = 0,
77  TWO_DOT_ONE = 1,
78  };
79 
80  gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* gsoapProxy2_0_1;
81  gsoap_eml2_1::eml21__AbstractObject* gsoapProxy2_1;
82  COMMON_NS::EpcDocument* epcDocument;
83  std::vector<RESQML2_NS::Activity*> activitySet;
84 
85  bool updateXml;
86 
87  //Default constructor
89 
93  AbstractObject(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject);
94 
95  AbstractObject(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* proxy);
96 
97  AbstractObject(gsoap_eml2_1::eml21__AbstractObject* proxy);
98 
100 
101  void initMandatoryMetadata();
102 
106  virtual void importRelationshipSetFromEpc(COMMON_NS::EpcDocument * epcDoc) = 0;
108 
112  virtual std::vector<epc::Relationship> getAllEpcRelationships() const = 0;
113  friend void COMMON_NS::EpcDocument::serialize(bool useZip64);
114 
115  // Only for Activity. Can not use friendness between AbstractObject and Activity for circular dependencies reason.
116  static void addActivityToResqmlObject(RESQML2_NS::Activity* activity, AbstractObject* resqmlObject);
117 
123  void setMetadata(const std::string & guid, const std::string & title, const std::string & editor, const time_t & creation, const std::string & originator,
124  const std::string & description, const time_t & lastUpdate, const std::string & format, const std::string & descriptiveKeywords);
125 
129  void cannotBePartial() const;
130 
134  void changeToPartialObject();
135 
136  public:
137  virtual ~AbstractObject() {}
138 
144  bool isPartial() const {return partialObject != nullptr;}
145 
146  std::string getUuid() const;
147  std::string getTitle() const;
148  std::string getEditor() const;
149  time_t getCreation() const;
153  tm getCreationAsTimeStructure() const;
154  std::string getOriginator() const;
155  std::string getDescription() const;
156  time_t getLastUpdate() const;
160  tm getLastUpdateAsTimeStructure() const;
161  std::string getFormat() const;
162  std::string getDescriptiveKeywords() const;
163  std::string getVersionString() const;
164 
165  void setTitle(const std::string & title);
166  void setEditor(const std::string & editor);
167  void setCreation(const time_t & creation);
171  void setCreation(const tm & creation);
172  void setOriginator(const std::string & originator);
173  void setDescription(const std::string & description);
174  void setLastUpdate(const time_t & lastUpdate);
178  void setLastUpdate(const tm & lastUpdate);
179  void setFormat(const std::string & format);
180  void setDescriptiveKeywords(const std::string & descriptiveKeywords);
181  void setVersionString(const std::string & versionString);
182 
187  void setMetadata(const std::string & title, const std::string & editor, const time_t & creation, const std::string & originator,
188  const std::string & description, const time_t & lastUpdate, const std::string & format, const std::string & descriptiveKeywords);
189 
194  void serializeIntoStream(std::ostream * stream);
195 
199  gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* getGsoapProxy() const;
200 
204  soap* getGsoapContext() const;
205 
209  int getGsoapType() const;
210 
211  gsoap_resqml2_0_1::eml20__DataObjectReference* newResqmlReference() const;
212  gsoap_eml2_1::eml21__DataObjectReference* newEmlReference() const;
213 
214  gsoap_resqml2_0_1::resqml2__ContactElementReference* newResqmlContactElementReference() const;
215 
219  COMMON_NS::EpcDocument* getEpcDocument() const {return epcDocument;}
220 
224  virtual std::string getXmlNamespace() const;
225 
229  virtual std::string getXmlTag() const = 0;
230 
234  virtual std::string getResqmlVersion() const;
235 
239  virtual std::string getContentType() const;
240 
244  virtual std::string getPartNameInEpcDocument() const;
245 
249  std::string serializeIntoString();
250 
254  void addAlias(const std::string & authority, const std::string & title);
255 
259  unsigned int getAliasCount() const;
260 
264  std::string getAliasAuthorityAtIndex(const unsigned int & index) const;
265 
269  std::string getAliasTitleAtIndex(const unsigned int & index) const;
270 
274  const std::vector<RESQML2_NS::Activity*> & getActivitySet() const;
275 
279  unsigned int getActivityCount() const;
280 
284  RESQML2_NS::Activity* getActivity (const unsigned int & index) const;
285 
289  void pushBackExtraMetadata(const std::string & key, const std::string & value);
290 
294 #if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
295  std::unordered_map< std::string, std::string > getExtraMetadataSet() const;
296 #else
297  std::tr1::unordered_map< std::string, std::string > getExtraMetadataSet() const;
298 #endif
299 
304  std::vector<std::string> getExtraMetadata(const std::string & key) const;
305 
309  unsigned int getExtraMetadataCount() const;
310 
314  std::string getExtraMetadataKeyAtIndex(const unsigned int & index) const;
315 
319  std::string getExtraMetadataStringValueAtIndex(const unsigned int & index) const;
320  };
321 }
322 
bool isPartial() const
Definition: AbstractObject.h:144
void updateAllRelationships()
Definition: EpcDocument.cpp:1457
void addGsoapProxy(COMMON_NS::AbstractObject *proxy)
Definition: EpcDocument.cpp:529
virtual void serialize(bool useZip64=false)
Definition: EpcDocument.cpp:665
Definition: EpcDocument.h:154
Definition: AbstractObject.h:27
COMMON_NS::EpcDocument * getEpcDocument() const
Definition: AbstractObject.h:219
Definition: Activity.h:25
Definition: AbstractHdfProxy.h:28