21#include <unordered_map>
26#include "DataObjectRepository.h"
35 enum class numericalDatatypeEnum { UNKNOWN = 0, DOUBLE = 1, FLOAT = 2, INT64 = 3, UINT64 = 4, INT32 = 5, UINT32 = 6, INT16 = 7, UINT16 = 8, INT8 = 9, UINT8 = 10};
48 DLL_IMPORT_OR_EXPORT
virtual bool isTopLevelElement()
const {
return true; }
59 DLL_IMPORT_OR_EXPORT std::string
getUuid()
const;
70 DLL_IMPORT_OR_EXPORT std::string
getTitle()
const;
204 DLL_IMPORT_OR_EXPORT
void setTitle(
const std::string & title);
216 DLL_IMPORT_OR_EXPORT
void setEditor(
const std::string & editor);
300 DLL_IMPORT_OR_EXPORT
static void setFormat(
const std::string & vendor,
const std::string & applicationName,
const std::string & applicationVersionNumber);
324 DLL_IMPORT_OR_EXPORT
void setVersion(
const std::string & version);
352 DLL_IMPORT_OR_EXPORT
void setMetadata(
const std::string & title,
const std::string & editor, time_t creation,
const std::string & originator,
353 const std::string & description, time_t lastUpdate,
const std::string & descriptiveKeywords);
370 gsoap_resqml2_0_1::eml20__AbstractCitedDataObject*
getEml20GsoapProxy()
const {
return gsoapProxy2_0_1; }
376 void setGsoapProxy(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* gsoapProxy) { gsoapProxy2_0_1 = gsoapProxy; }
389 void setGsoapProxy(gsoap_eml2_3::eml23__AbstractObject* gsoapProxy) { gsoapProxy2_3 = gsoapProxy; }
440 DLL_IMPORT_OR_EXPORT COMMON_NS::DataObjectRepository*
getRepository()
const {
return repository;}
454 DLL_IMPORT_OR_EXPORT
virtual std::string
getXmlTag()
const = 0;
501 DLL_IMPORT_OR_EXPORT
void addAlias(
const std::string & authority,
const std::string & title);
568 DLL_IMPORT_OR_EXPORT EML2_NS::Activity*
getActivity(
unsigned int index)
const;
598 DLL_IMPORT_OR_EXPORT std::vector<std::string>
getExtraMetadata(
const std::string & key)
const;
639 std::string tmp = uriSource_.empty() ?
"eml:///" : uriSource_;
640 return (tmp.back() ==
'/' ? tmp : tmp +
'/') + getQualifiedType() +
'(' + getUuid() +
')';
646 DLL_IMPORT_OR_EXPORT
void setUriSource(
const std::string & uriSource) { uriSource_ = uriSource; }
651 DLL_IMPORT_OR_EXPORT
const std::string&
getUriSource()
const {
return uriSource_; }
658 if (uriSource_.find(
".epc") != uriSource_.size() - 4 &&
659 uriSource_.find(
".EPC") != uriSource_.size() - 4) {
663 const size_t slashPos = uriSource_.find_last_of(
"/\\");
664 return slashPos != std::string::npos ? uriSource_.substr(0, slashPos + 1) :
"";
680 gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject;
683 gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* gsoapProxy2_0_1;
686 gsoap_eml2_3::eml23__AbstractObject* gsoapProxy2_3;
689 COMMON_NS::DataObjectRepository* repository;
695 partialObject(nullptr),
696 gsoapProxy2_0_1(nullptr),
697 gsoapProxy2_3(nullptr),
698 repository(nullptr) {}
705 AbstractObject(gsoap_resqml2_0_1::eml20__DataObjectReference* partialObject_) :
706 partialObject(partialObject_),
707 gsoapProxy2_0_1(nullptr),
708 gsoapProxy2_3(nullptr),
709 repository(nullptr) {}
710 AbstractObject(
const DataObjectReference& dor) :
711 partialObject(dor.toDor20()),
712 gsoapProxy2_0_1(nullptr),
713 gsoapProxy2_3(nullptr),
714 repository(nullptr) {}
721 AbstractObject(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject* proxy) :
722 partialObject(nullptr),
723 gsoapProxy2_0_1(proxy),
724 gsoapProxy2_3(nullptr),
725 repository(nullptr) {}
732 AbstractObject(gsoap_eml2_3::eml23__AbstractObject* proxy) :
733 partialObject(nullptr),
734 gsoapProxy2_0_1(nullptr),
735 gsoapProxy2_3(proxy),
736 repository(nullptr) {}
739 friend bool COMMON_NS::DataObjectRepository::addDataObject(COMMON_NS::AbstractObject* proxy);
740 friend COMMON_NS::AbstractObject* COMMON_NS::DataObjectRepository::addOrReplaceDataObject(AbstractObject* proxy,
bool replaceOnlyContent);
746 void initMandatoryMetadata();
764 void setMetadata(
const std::string & guid,
const std::string & title,
const std::string & editor, time_t creation,
const std::string & originator,
765 const std::string & description, time_t lastUpdate,
const std::string & descriptiveKeywords);
768 void cannotBePartial()
const;
777 void readArrayNdOfFloatValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray
const* arrayInput,
float* arrayOutput)
const;
786 void readArrayNdOfFloatValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray
const* arrayInput,
float* arrayOutput)
const;
795 void readArrayNdOfDoubleValues(gsoap_resqml2_0_1::resqml20__AbstractDoubleArray
const* arrayInput,
double * arrayOutput)
const;
804 void readArrayNdOfDoubleValues(gsoap_eml2_3::eml23__AbstractFloatingPointArray
const* arrayInput,
double * arrayOutput)
const;
807 void readArrayNdOfNonHdf5IntegerValues(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const * arrayInput, T * arrayOutput)
const {
808 switch (arrayInput->soap_type()) {
809 case SOAP_TYPE_gsoap_resqml2_0_1_resqml20__IntegerRangeArray:
811 gsoap_resqml2_0_1::resqml20__IntegerRangeArray
const* rangeArray =
static_cast<gsoap_resqml2_0_1::resqml20__IntegerRangeArray
const *
>(arrayInput);
812 if (rangeArray->Value + rangeArray->Count > (std::numeric_limits<T>::max)()) {
813 throw std::range_error(
"The range integer values are superior to unsigned int maximum value.");
815 for (
unsigned int i = 0; i < static_cast<T>(rangeArray->Count); ++i) {
816 arrayOutput[i] = i +
static_cast<T
>(rangeArray->Value);
820 case SOAP_TYPE_gsoap_resqml2_0_1_resqml20__IntegerConstantArray:
822 gsoap_resqml2_0_1::resqml20__IntegerConstantArray
const* constantArray =
static_cast<gsoap_resqml2_0_1::resqml20__IntegerConstantArray const*
>(arrayInput);
823 if (constantArray->Value > (std::numeric_limits<T>::max)()) {
824 throw std::range_error(
"The constant integer value is superior to unsigned int maximum value.");
826 for (
size_t i = 0; i < constantArray->Count; ++i) {
827 arrayOutput[i] =
static_cast<T
>(constantArray->Value);
831 case SOAP_TYPE_gsoap_resqml2_0_1_resqml20__IntegerLatticeArray:
833 gsoap_resqml2_0_1::resqml20__IntegerLatticeArray
const* latticeArray =
static_cast<gsoap_resqml2_0_1::resqml20__IntegerLatticeArray const*
>(arrayInput);
834 if (latticeArray->Offset.size() > 1) {
835 throw std::invalid_argument(
"The integer lattice array contains more than one offset.");
837 for (
size_t i = 0; i <= latticeArray->Offset[0]->Count; ++i) {
838 arrayOutput[i] = latticeArray->StartValue + (i * latticeArray->Offset[0]->Value);
843 throw std::invalid_argument(
"The integer array type is not supported yet.");
848 T readArrayNdOfNonHdf5IntegerValues(gsoap_eml2_3::eml23__AbstractIntegerArray
const * arrayInput, T * arrayOutput)
const {
849 switch (arrayInput->soap_type()) {
850 case SOAP_TYPE_gsoap_eml2_3_eml23__IntegerConstantArray:
852 gsoap_eml2_3::eml23__IntegerConstantArray
const* constantArray =
static_cast<gsoap_eml2_3::eml23__IntegerConstantArray const*
>(arrayInput);
853 if (constantArray->Value > (std::numeric_limits<T>::max)()) {
854 throw std::range_error(
"The constant integer value is superior to maximum value of read datatype.");
856 std::fill(arrayOutput, arrayOutput + constantArray->Count,
static_cast<T
>(constantArray->Value));
857 return (std::numeric_limits<T>::max)();
859 case SOAP_TYPE_gsoap_eml2_3_eml23__IntegerLatticeArray:
861 gsoap_eml2_3::eml23__IntegerLatticeArray
const* latticeArray =
static_cast<gsoap_eml2_3::eml23__IntegerLatticeArray const*
>(arrayInput);
862 if (latticeArray->Offset.empty() || latticeArray->Offset.size() > 1) {
863 throw std::invalid_argument(
"The integer lattice array of UUID " + getUuid() +
" contains zero or more than one offset.");
865 if (latticeArray->Offset[0]->Count < 0) {
866 throw std::invalid_argument(
"The count of the integer lattice array of UUID " + getUuid() +
" is negative which is not valid.");
869 for (
size_t i = 0; i <= static_cast<size_t>(latticeArray->Offset[0]->Count); ++i) {
870 arrayOutput[i] = latticeArray->StartValue + (i * latticeArray->Offset[0]->Value);
872 return (std::numeric_limits<T>::max)();
874 case SOAP_TYPE_gsoap_eml2_3_eml23__IntegerXmlArray:
876 gsoap_eml2_3::eml23__IntegerXmlArray
const * xmlArray =
static_cast<gsoap_eml2_3::eml23__IntegerXmlArray const*
>(arrayInput);
877 std::istringstream iss(xmlArray->Values);
878 auto str = std::string{};
881 arrayOutput[index++] = std::stoll(str);
883 return (std::numeric_limits<T>::max)();
885 default:
throw std::invalid_argument(
"The integer array type is not supported yet.");
898 uint8_t readArrayNdOfUInt8Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, uint8_t * arrayOutput)
const;
909 uint8_t readArrayNdOfUInt8Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, uint8_t * arrayOutput)
const;
920 uint16_t readArrayNdOfUInt16Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, uint16_t * arrayOutput)
const;
931 uint16_t readArrayNdOfUInt16Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, uint16_t * arrayOutput)
const;
942 uint32_t readArrayNdOfUInt32Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, uint32_t * arrayOutput)
const;
953 uint32_t readArrayNdOfUInt32Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, uint32_t * arrayOutput)
const;
964 uint64_t readArrayNdOfUInt64Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, uint64_t * arrayOutput)
const;
975 uint64_t readArrayNdOfUInt64Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, uint64_t * arrayOutput)
const;
986 int8_t readArrayNdOfInt8Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, int8_t * arrayOutput)
const;
997 int8_t readArrayNdOfInt8Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, int8_t * arrayOutput)
const;
1008 int16_t readArrayNdOfInt16Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, int16_t * arrayOutput)
const;
1019 int16_t readArrayNdOfInt16Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, int16_t * arrayOutput)
const;
1030 int32_t readArrayNdOfInt32Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, int32_t * arrayOutput)
const;
1041 int32_t readArrayNdOfInt32Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, int32_t * arrayOutput)
const;
1052 int64_t readArrayNdOfInt64Values(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput, int64_t * arrayOutput)
const;
1063 int64_t readArrayNdOfInt64Values(gsoap_eml2_3::eml23__AbstractIntegerArray
const* arrayInput, int64_t * arrayOutput)
const;
1072 uint64_t getCountOfIntegerArray(gsoap_resqml2_0_1::resqml20__AbstractIntegerArray
const* arrayInput)
const;
1081 uint64_t getCountOfArray(gsoap_eml2_3::eml23__AbstractValueArray
const * arrayInput)
const;
1088 void convertDorIntoRel(
const DataObjectReference& dor);
1099 template <
class valueType>
1100 void convertDorIntoRel(
const DataObjectReference& dor)
1102 valueType * targetObj = getRepository()->getDataObjectByUuid<valueType>(dor.getUuid());
1103 if (targetObj ==
nullptr) {
1104 getRepository()->createPartial(dor);
1105 targetObj = getRepository()->getDataObjectByUuid<valueType>(dor.getUuid());
1106 if (targetObj ==
nullptr) {
1107 throw std::invalid_argument(
"The DOR looks invalid.");
1109 targetObj->setUriSource(getUriSource());
1111 getRepository()->addRelationship(
this, targetObj);
1125 EML2_NS::AbstractHdfProxy* getHdfProxyFromDataset(gsoap_resqml2_0_1::eml20__Hdf5Dataset
const * dataset,
bool throwException =
true)
const;
1137 EML2_NS::AbstractHdfProxy* getOrCreateHdfProxyFromDataArrayPart(gsoap_eml2_3::eml23__ExternalDataArrayPart
const * dataArrayPart)
const;
1142 std::string getHdfGroup()
const {
1143 return "/" + getXmlNamespace() +
"/" + getUuid();
1149 gsoap_eml2_3::eml23__ExternalDataArrayPart* createExternalDataArrayPart(
const std::string& datasetName, LONG64 count, EML2_NS::AbstractHdfProxy* proxy =
nullptr)
const;
1151 gsoap_resqml2_0_1::resqml20__IndexableElements mapIndexableElement(gsoap_eml2_3::eml23__IndexableElement toMap)
const;
1155 static char citationFormat[];
1160 std::string uriSource_;
1169 void setUuid(
const std::string & uuid);
An abstract data object.
Definition AbstractObject.h:32
soap * getGsoapContext() const
std::vector< eml2 ::Activity * > getActivitySet() const
void setCreation(const tm &creation)
void setGsoapProxy(gsoap_eml2_3::eml23__AbstractObject *gsoapProxy)
Definition AbstractObject.h:389
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
gsoap_eml2_3::resqml22__ContactElement * newContactElementReference2_2() const
std::string serializeIntoString()
std::string buildEtp12Uri() const
Definition AbstractObject.h:638
unsigned int getExtraMetadataCount() const
std::string getDescriptiveKeywords() const
gsoap_resqml2_0_1::eml20__DataObjectReference * newResqmlReference() const
virtual std::string getXmlNamespaceVersion() const
common::DataObjectRepository * getRepository() const
Definition AbstractObject.h:440
void setUriSource(const std::string &uriSource)
Definition AbstractObject.h:646
std::string getEditor() const
void changeToPartialObject()
gsoap_eml2_3::eml23__DataObjectReference * newEml23Reference() const
std::string getAliasTitleAtIndex(unsigned int index) const
virtual std::string getQualifiedType() const
void setEditor(const std::string &editor)
void setLastUpdate(time_t lastUpdate)
std::string getUuid() const
std::string getAliasAuthorityAtIndex(unsigned int index) const
void setDescription(const std::string &description)
void serializeIntoStream(std::ostream *stream)
void setDescriptiveKeywords(const std::string &descriptiveKeywords)
virtual std::string getXmlNamespace() const =0
void setCreation(time_t creation)
gsoap_resqml2_0_1::resqml20__ContactElementReference * newContactElementReference2_0_1() const
void pushBackExtraMetadata(const std::string &key, const std::string &value)
const std::string & getUriSource() const
Definition AbstractObject.h:651
void setLastUpdate(const tm &lastUpdate)
eml2::Activity * getActivity(unsigned int index) const
gsoap_resqml2_0_1::eml20__AbstractCitedDataObject * getEml20GsoapProxy() const
Definition AbstractObject.h:370
gsoap_eml2_3::eml23__AbstractObject * getEml23GsoapProxy() const
Definition AbstractObject.h:383
std::vector< std::string > getExtraMetadata(const std::string &key) const
std::string getOriginator() const
void setGsoapProxy(gsoap_resqml2_0_1::eml20__AbstractCitedDataObject *gsoapProxy)
Definition AbstractObject.h:376
tm getCreationAsTimeStructure() const
std::string getEpcSourceFolder() const
Definition AbstractObject.h:657
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
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
std::string getTitle() const
std::string getFormat() const
std::string getExtraMetadataKeyAtIndex(unsigned int index) const