21 #include <unordered_map>
25 #include "DataObjectRepository.h"
34 static char citationFormat[];
43 void setUuid(
const std::string & uuid);
47 gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject;
50 gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* gsoapProxy2_0_1;
53 gsoap_eml2_1::eml21__AbstractObject* gsoapProxy2_1;
56 gsoap_eml2_2::eml22__AbstractObject* gsoapProxy2_2;
59 gsoap_eml2_3::eml23__AbstractObject* gsoapProxy2_3;
62 COMMON_NS::DataObjectRepository* repository;
68 partialObject(
nullptr), gsoapProxy2_0_1(
nullptr),
69 gsoapProxy2_1(
nullptr),
70 gsoapProxy2_2(
nullptr),
71 gsoapProxy2_3(
nullptr),
72 repository(
nullptr) {}
79 AbstractObject(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject_) :
80 partialObject(partialObject_), gsoapProxy2_0_1(
nullptr),
81 gsoapProxy2_1(
nullptr),
82 gsoapProxy2_2(
nullptr),
83 gsoapProxy2_3(
nullptr),
84 repository(
nullptr) {}
86 partialObject(dor.
toDor20()), gsoapProxy2_0_1(
nullptr),
87 gsoapProxy2_1(
nullptr),
88 gsoapProxy2_2(
nullptr),
89 gsoapProxy2_3(
nullptr),
90 repository(
nullptr) {}
97 AbstractObject(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* proxy) :
98 partialObject(
nullptr), gsoapProxy2_0_1(proxy),
99 gsoapProxy2_1(
nullptr),
100 gsoapProxy2_2(
nullptr),
101 gsoapProxy2_3(
nullptr),
102 repository(
nullptr) {}
110 partialObject(
nullptr), gsoapProxy2_0_1(
nullptr),
111 gsoapProxy2_1(proxy),
112 gsoapProxy2_2(
nullptr),
113 gsoapProxy2_3(
nullptr),
114 repository(
nullptr) {}
122 partialObject(
nullptr), gsoapProxy2_0_1(
nullptr),
123 gsoapProxy2_1(
nullptr),
124 gsoapProxy2_2(proxy),
125 gsoapProxy2_3(
nullptr),
126 repository(
nullptr) {}
134 partialObject(
nullptr), gsoapProxy2_0_1(
nullptr),
135 gsoapProxy2_1(
nullptr),
136 gsoapProxy2_2(
nullptr),
137 gsoapProxy2_3(proxy),
138 repository(
nullptr) {}
148 friend COMMON_NS::AbstractObject* COMMON_NS::DataObjectRepository::addOrReplaceDataObject(
AbstractObject* proxy,
bool replaceOnlyContent);
154 void initMandatoryMetadata();
172 void setMetadata(
const std::string & guid,
const std::string & title,
const std::string & editor, time_t creation,
const std::string & originator,
173 const std::string & description, time_t lastUpdate,
const std::string & descriptiveKeywords);
176 void cannotBePartial()
const;
179 void changeToPartialObject();
188 void readArrayNdOfDoubleValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray * arrayInput,
double * arrayOutput)
const;
197 void readArrayNdOfDoubleValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray * arrayInput,
double * arrayOutput)
const;
200 void readArrayNdOfNonHdf5IntegerValues(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const * arrayInput, T * arrayOutput)
const {
201 switch (arrayInput->soap_type()) {
202 case SOAP_TYPE_gsoap_resqml2_0_1_resqml20__IntegerRangeArray:
204 gsoap_resqml2_0_1::resqml20__IntegerRangeArray
const* rangeArray =
static_cast<gsoap_resqml2_0_1::resqml20__IntegerRangeArray
const *
>(arrayInput);
205 if (rangeArray->Value + rangeArray->Count > (std::numeric_limits<T>::max)()) {
206 throw std::range_error(
"The range integer values are superior to unsigned int maximum value.");
208 for (
unsigned int i = 0; i < static_cast<T>(rangeArray->Count); ++i) {
209 arrayOutput[i] = i +
static_cast<T
>(rangeArray->Value);
213 case SOAP_TYPE_gsoap_resqml2_0_1_resqml20__IntegerConstantArray:
215 gsoap_resqml2_0_1::resqml20__IntegerConstantArray
const* constantArray =
static_cast<gsoap_resqml2_0_1::resqml20__IntegerConstantArray const*
>(arrayInput);
216 if (constantArray->Value > (std::numeric_limits<T>::max)()) {
217 throw std::range_error(
"The constant integer value is superior to unsigned int maximum value.");
219 for (
size_t i = 0; i < constantArray->Count; ++i) {
220 arrayOutput[i] =
static_cast<T
>(constantArray->Value);
224 case SOAP_TYPE_gsoap_resqml2_0_1_resqml20__IntegerLatticeArray:
226 gsoap_resqml2_0_1::resqml20__IntegerLatticeArray
const* latticeArray =
static_cast<gsoap_resqml2_0_1::resqml20__IntegerLatticeArray const*
>(arrayInput);
227 if (latticeArray->Offset.size() > 1) {
228 throw std::invalid_argument(
"The integer lattice array contains more than one offset.");
230 for (
size_t i = 0; i <= latticeArray->Offset[0]->Count; ++i) {
231 arrayOutput[i] = latticeArray->StartValue + (i * latticeArray->Offset[0]->Value);
236 throw std::invalid_argument(
"The integer array type is not supported yet.");
241 void readArrayNdOfNonHdf5IntegerValues(gsoap_eml2_3::eml23__AbstractIntegerArray
const * arrayInput, T * arrayOutput)
const {
242 switch (arrayInput->soap_type()) {
243 case SOAP_TYPE_gsoap_eml2_3_eml23__IntegerRangeArray:
245 gsoap_eml2_3::eml23__IntegerRangeArray
const* rangeArray =
static_cast<gsoap_eml2_3::eml23__IntegerRangeArray const*
>(arrayInput);
246 if (rangeArray->Value + rangeArray->Count > (std::numeric_limits<T>::max)()) {
247 throw std::range_error(
"The range integer values are superior to unsigned int maximum value.");
249 for (
unsigned int i = 0; i < static_cast<T>(rangeArray->Count); ++i) {
250 arrayOutput[i] = i +
static_cast<T
>(rangeArray->Value);
254 case SOAP_TYPE_gsoap_eml2_3_eml23__IntegerConstantArray:
256 gsoap_eml2_3::eml23__IntegerConstantArray
const* constantArray =
static_cast<gsoap_eml2_3::eml23__IntegerConstantArray const*
>(arrayInput);
257 if (constantArray->Value > (std::numeric_limits<T>::max)()) {
258 throw std::range_error(
"The constant integer value is superior to unsigned int maximum value.");
260 std::fill(arrayOutput, arrayOutput + constantArray->Count,
static_cast<T
>(constantArray->Value));
263 case SOAP_TYPE_gsoap_eml2_3_eml23__IntegerLatticeArray:
265 gsoap_eml2_3::eml23__IntegerLatticeArray
const* latticeArray =
static_cast<gsoap_eml2_3::eml23__IntegerLatticeArray const*
>(arrayInput);
266 if (latticeArray->Offset.size() > 1) {
267 throw std::invalid_argument(
"The integer lattice array contains more than one offset.");
269 for (
size_t i = 0; i <= latticeArray->Offset[0]->Count; ++i) {
270 arrayOutput[i] = latticeArray->StartValue + (i * latticeArray->Offset[0]->Value);
274 default:
throw std::invalid_argument(
"The integer array type is not supported yet.");
287 uint8_t readArrayNdOfUInt8Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const * arrayInput, uint8_t * arrayOutput)
const;
298 uint8_t readArrayNdOfUInt8Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const * arrayInput, uint8_t * arrayOutput)
const;
309 uint16_t readArrayNdOfUInt16Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const * arrayInput, uint16_t * arrayOutput)
const;
320 uint16_t readArrayNdOfUInt16Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const * arrayInput, uint16_t * arrayOutput)
const;
331 uint32_t readArrayNdOfUInt32Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const * arrayInput, uint32_t * arrayOutput)
const;
342 uint32_t readArrayNdOfUInt32Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const * arrayInput, uint32_t * arrayOutput)
const;
353 uint64_t readArrayNdOfUInt64Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const * arrayInput, uint64_t * arrayOutput)
const;
364 uint64_t readArrayNdOfUInt64Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const * arrayInput, uint64_t * arrayOutput)
const;
373 uint64_t getCountOfIntegerArray(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray * arrayInput)
const;
382 uint64_t getCountOfIntegerArray(gsoap_eml2_3::eml23__AbstractIntegerArray * arrayInput)
const;
389 void convertDorIntoRel(
const DataObjectReference& dor);
400 template <
class valueType>
401 void convertDorIntoRel(
const DataObjectReference& dor)
403 valueType * targetObj = getRepository()->getDataObjectByUuid<valueType>(dor.getUuid());
404 if (targetObj ==
nullptr) {
405 getRepository()->createPartial(dor);
406 targetObj = getRepository()->getDataObjectByUuid<valueType>(dor.getUuid());
407 if (targetObj ==
nullptr) {
408 throw std::invalid_argument(
"The DOR looks invalid.");
411 getRepository()->addRelationship(
this, targetObj);
425 EML2_NS::AbstractHdfProxy* getHdfProxyFromDataset(gsoap_resqml2_0_1::eml20__Hdf5Dataset
const * dataset,
bool throwException =
true)
const;
438 EML2_NS::AbstractHdfProxy* getHdfProxyFromDataset(gsoap_eml2_3::eml23__ExternalDatasetPart
const * dataset,
bool throwException =
true)
const;
443 std::string getHdfGroup()
const {
444 return "/" + getXmlNamespace() +
"/" + getUuid();
447 gsoap_resqml2_0_1::resqml20__IndexableElements mapIndexableElement(gsoap_eml2_3::resqml22__IndexableElement toMap)
const;
451 enum hdfDatatypeEnum { UNKNOWN = 0, DOUBLE = 1, FLOAT = 2, LONG_64 = 3, ULONG_64 = 4, INT = 5, UINT = 6, SHORT = 7, USHORT = 8, CHAR = 9, UCHAR = 10};
453 DLL_IMPORT_OR_EXPORT
virtual ~AbstractObject() =
default;
464 DLL_IMPORT_OR_EXPORT
virtual bool isTopLevelElement()
const {
return true; }
475 DLL_IMPORT_OR_EXPORT std::string
getUuid()
const;
620 DLL_IMPORT_OR_EXPORT
void setTitle(
const std::string & title);
632 DLL_IMPORT_OR_EXPORT
void setEditor(
const std::string & editor);
716 DLL_IMPORT_OR_EXPORT
static void setFormat(
const std::string & vendor,
const std::string & applicationName,
const std::string & applicationVersionNumber);
740 DLL_IMPORT_OR_EXPORT
void setVersion(
const std::string & version);
768 DLL_IMPORT_OR_EXPORT
void setMetadata(
const std::string & title,
const std::string & editor, time_t creation,
const std::string & originator,
769 const std::string & description, time_t lastUpdate,
const std::string & descriptiveKeywords);
786 void setGsoapProxy(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* gsoapProxy) { gsoapProxy2_0_1 = gsoapProxy; }
788 void setGsoapProxy(gsoap_eml2_1::eml21__AbstractObject* gsoapProxy) { gsoapProxy2_1 = gsoapProxy; }
795 gsoap_resqml2_0_1::eml20__AbstractCitedDataObject*
getEml20GsoapProxy()
const {
return gsoapProxy2_0_1; }
804 gsoap_eml2_2::eml22__AbstractObject* getEml22GsoapProxy()
const {
return gsoapProxy2_2; }
805 void setGsoapProxy(gsoap_eml2_2::eml22__AbstractObject* gsoapProxy) { gsoapProxy2_2 = gsoapProxy; }
813 void setGsoapProxy(gsoap_eml2_3::eml23__AbstractObject* gsoapProxy) { gsoapProxy2_3 = gsoapProxy; }
843 DLL_IMPORT_OR_EXPORT gsoap_eml2_1::eml21__DataObjectReference*
newEmlReference()
const;
878 DLL_IMPORT_OR_EXPORT COMMON_NS::DataObjectRepository*
getRepository()
const {
return repository;}
892 DLL_IMPORT_OR_EXPORT
virtual std::string
getXmlTag()
const = 0;
939 DLL_IMPORT_OR_EXPORT
void addAlias(
const std::string & authority,
const std::string & title);
1006 DLL_IMPORT_OR_EXPORT EML2_NS::Activity*
getActivity(
unsigned int index)
const;
An abstract data object.
Definition: AbstractObject.h:31
void setCreation(const tm &creation)
void setVersion(const std::string &version)
unsigned int getAliasCount() const
std::string getVersion() const
virtual std::string getContentType() const
void setTitle(const std::string &title)
std::unordered_map< std::string, std::string > getExtraMetadataSet() const
time_t getCreation() const
virtual void loadTargetRelationships()=0
std::string getExtraMetadataStringValueAtIndex(unsigned int index) const
std::string serializeIntoString()
gsoap_eml2_1::eml21__AbstractObject * getEml21GsoapProxy() const
Definition: AbstractObject.h:802
unsigned int getExtraMetadataCount() const
std::string getDescriptiveKeywords() const
virtual std::string getXmlNamespaceVersion() const
gsoap_resqml2_0_1::eml20__DataObjectReference * newResqmlReference() const
std::string getEditor() const
gsoap_resqml2_0_1::resqml20__ContactElementReference * newContactElementReference2_0_1() const
common::DataObjectRepository * getRepository() const
Definition: AbstractObject.h:878
std::string getAliasTitleAtIndex(unsigned int index) const
virtual std::string getQualifiedType() const
void setEditor(const std::string &editor)
void setLastUpdate(time_t lastUpdate)
gsoap_resqml2_0_1::eml20__AbstractCitedDataObject * getEml20GsoapProxy() const
Definition: AbstractObject.h:795
soap * getGsoapContext() const
std::vector< eml2::Activity * > getActivitySet() const
std::string getUuid() const
gsoap_eml2_2::eml22__DataObjectReference * newEml22Reference() const
std::string getAliasAuthorityAtIndex(unsigned int index) const
void setDescription(const std::string &description)
gsoap_eml2_1::eml21__DataObjectReference * newEmlReference() const
void serializeIntoStream(std::ostream *stream)
void setDescriptiveKeywords(const std::string &descriptiveKeywords)
virtual std::string getXmlNamespace() const =0
void setCreation(time_t creation)
void pushBackExtraMetadata(const std::string &key, const std::string &value)
gsoap_eml2_3::eml23__AbstractObject * getEml23GsoapProxy() const
Definition: AbstractObject.h:812
void setLastUpdate(const tm &lastUpdate)
std::vector< std::string > getExtraMetadata(const std::string &key) const
eml2::Activity * getActivity(unsigned int index) const
std::string getOriginator() const
void setGsoapProxy(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject *gsoapProxy)
Definition: AbstractObject.h:786
tm getCreationAsTimeStructure() const
tm getLastUpdateAsTimeStructure() const
void setMetadata(const std::string &title, const std::string &editor, time_t creation, const std::string &originator, const std::string &description, time_t lastUpdate, const std::string &descriptiveKeywords)
void setOriginator(const std::string &originator)
virtual std::string getPartNameInEpcDocument() const
std::string getDescription() const
gsoap_eml2_3::eml23__DataObjectReference * newEml23Reference() const
time_t getLastUpdate() const
static void setFormat(const std::string &vendor, const std::string &applicationName, const std::string &applicationVersionNumber)
virtual std::string getXmlTag() const =0
void addAlias(const std::string &authority, const std::string &title)
unsigned int getActivityCount() const
gsoap_eml2_3::resqml22__ContactElement * newContactElementReference2_2() const
std::string getTitle() const
std::string getFormat() const
std::string getExtraMetadataKeyAtIndex(unsigned int index) const
This class wraps an Energistics Data Object Reference whatever its version is.
Definition: DataObjectReference.h:43
gsoap_resqml2_0_1::eml20__DataObjectReference * toDor20() const
Definition: DataObjectReference.h:194