C++: add runlimits to Vouchers
authorjani <jani@asema.com>
Thu, 17 Oct 2019 09:34:00 +0000 (12:34 +0300)
committerjani <jani@asema.com>
Thu, 17 Oct 2019 09:34:00 +0000 (12:34 +0300)
Common/C++/SmartAPI/build.sh
Common/C++/SmartAPI/smartapi/common/PROPERTY.h
Common/C++/SmartAPI/smartapi/model/Voucher.cpp
Common/C++/SmartAPI/smartapi/model/Voucher.h

index 5fdd91f005a164c62ea8a236f7dd171e247cc7e6..e5c850c2b918edd0f507348d1c6bc301218a2379 100755 (executable)
@@ -1,12 +1,12 @@
 #!/bin/bash
 
-/home/villep/Qt/5.11.0/gcc_64/bin/qmake smartapi.pro -o Makefile.lib && \
-/home/villep/Qt/5.11.0/gcc_64/bin/qmake smartapitests.pro -o Makefile.objecttests && \
-/home/villep/Qt/5.11.0/gcc_64/bin/qmake smartapitests.pro -o Makefile.agenttests && \
-/home/villep/Qt/5.11.0/gcc_64/bin/qmake smartapigraphtests.pro -o Makefile.graphtests && \
-/home/villep/Qt/5.11.0/gcc_64/bin/qmake smartapiplugintests.pro -o Makefile.plugintests && \
-/home/villep/Qt/5.11.0/gcc_64/bin/qmake smartapiplugin.pro -o Makefile.plugin && \
-\
+/opt/Qt/5.12.2/gcc_64/bin/qmake smartapi.pro -o Makefile.lib && \
+/opt/Qt/5.12.2/gcc_64/bin/qmake smartapitests.pro -o Makefile.objecttests && \
+/opt/Qt/5.12.2/gcc_64/bin/qmake smartapitests.pro -o Makefile.agenttests && \
+/opt/Qt/5.12.2/gcc_64/bin/qmake smartapigraphtests.pro -o Makefile.graphtests && \
+/opt/Qt/5.12.2/gcc_64/bin/qmake smartapiplugintests.pro -o Makefile.plugintests && \
+/opt/Qt/5.12.2/gcc_64/bin/qmake smartapiplugin.pro -o Makefile.plugin && \
+
 make -f Makefile.lib -j 3 && \
 make -f Makefile.objecttests -j 2 && \
 make -f Makefile.graphtests -j 2 && \
index 005ebefd6010f1727ef81393b960e75048851a3c..e81e08626480cff032e3d05aa33b557dd0fe3aec 100644 (file)
 #define PROPERTY__ORGANIZATION         "http://smart-api.io/ontology/1.0/smartapi#organization"
 #define PROPERTY__GROUP                "http://smart-api.io/ontology/1.0/smartapi#group"
 #define PROPERTY__PROMOCODE            "http://smart-api.io/ontology/1.0/smartapi#promoCode"
+#define PROPERTY__TIMELIMIT            "http://smart-api.io/ontology/1.0/smartapi#timeLimit"
 
 #endif //__PROPERTY_H__
index 398fbaddb5b3f9c2894e924721bcf4d3e4e0a55b..0236ac689bf48702a136f9740eed57507f3555cb 100755 (executable)
@@ -10,6 +10,7 @@ Voucher::Voucher(QString identifierUri)
        setType(RESOURCE__VOUCHER);
        INIT_PROPERTY(mMaxAvailable)
        INIT_PROPERTY(mPromoCode)
+       INIT_PROPERTY(mRunLimit)
 }
 
 Voucher::Voucher(QString identifierUri, QString name, QString description)
@@ -21,6 +22,8 @@ Voucher::Voucher(QString identifierUri, QString name, QString description)
 Voucher::Voucher(Voucher* o) : Offering(o)
 {
        SET_PROPERTY_REFERENCE(PROPERTY__MAXAVAILABLE, mMaxAvailable, Variant);
+       SET_PROPERTY_REFERENCE(PROPERTY__PROMOCODE, mPromoCode, Variant);
+       SET_PROPERTY_REFERENCE(PROPERTY__TIMELIMIT, mRunLimit, TemporalContext);
        setType(RESOURCE__VOUCHER);
 }
 
@@ -45,5 +48,7 @@ void Voucher::parse(Statement* statement)
        INIT_PARSE(statement)
        PARSE_PROPERTY(PROPERTY__MAXAVAILABLE, setMaxAvailable, Variant)
        PARSE_PROPERTY(PROPERTY__PROMOCODE, setPromoCode, Variant)
+       PARSE_PROPERTY(PROPERTY__TIMELIMIT, setRunLimit, TemporalContext)
+
        FINISH_PARSE(Offering)
 }
index 5f401c8c6a2aeec42934b2b0736115e6d8bbbc85..3b5f6e66b24d11a1da788ec7d960386d23d24df1 100644 (file)
@@ -2,6 +2,7 @@
 #define _VOUCHER_H_
 
 #include "smartapi/model/Offering.h"
+#include "smartapi/model/TemporalContext.h"
 
 class Voucher : public Offering
 {
@@ -25,9 +26,14 @@ public:
        void setPromoCode(QString c)                                                                            { setPromoCode(new Variant(c)); }
        QString getPromoCode()                                                                                          { PROPERTYVAL(mPromoCode, asString, QString()); }
 
+       bool hasRunLimit()                                                                                                      { return mRunLimit != NULL; }
+       void setRunLimit(TemporalContext* l)                                                            { add(PROPERTY__TIMELIMIT, l); mRunLimit = l; }
+       TemporalContext* getRunLimit()                                                                          { return mRunLimit; }
+
 private:
        Variant* mMaxAvailable;
        Variant* mPromoCode;
+       TemporalContext* mRunLimit;
 };
 
 #endif // _VOUCHER_H_