C++: Inherit all location price specifications from commom
authorjani <jani@asema.com>
Wed, 27 Feb 2019 18:45:00 +0000 (20:45 +0200)
committerjani <jani@asema.com>
Wed, 27 Feb 2019 18:45:00 +0000 (20:45 +0200)
LocationDependentPriceSpecification

27 files changed:
Common/C++/SmartAPI/smartapi.pro
Common/C++/SmartAPI/smartapi/agents/SearchAgent.cpp
Common/C++/SmartAPI/smartapi/agents/SearchAgent.h
Common/C++/SmartAPI/smartapi/common/ClassMapper.h
Common/C++/SmartAPI/smartapi/common/PROPERTY.h
Common/C++/SmartAPI/smartapi/common/RESOURCE.h
Common/C++/SmartAPI/smartapi/model/DistanceDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/DurationAtDistanceDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/DurationAtDistanceDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/DurationAtZoneDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/DurationAtZoneDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/LocationDependentPriceSpecification.cpp [new file with mode: 0644]
Common/C++/SmartAPI/smartapi/model/LocationDependentPriceSpecification.h [new file with mode: 0644]
Common/C++/SmartAPI/smartapi/model/PriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/PriceSpecification.h
Common/C++/SmartAPI/smartapi/model/TravelDistanceDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/TravelDistanceDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/TravelDistanceDurationDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/TravelDistanceDurationDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/ZoneDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/ZoneDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/ZonePopulationDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/ZonePopulationDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/ZoneTravelDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/ZoneTravelDependentPriceSpecification.h
Common/C++/SmartAPI/smartapi/model/ZoneTravelDurationDependentPriceSpecification.cpp
Common/C++/SmartAPI/smartapi/model/ZoneTravelDurationDependentPriceSpecification.h

index c42c148ab1493745bb7838f50032467a21338948..932d7e9def50e961c00b09b0130eccf0f7788636 100644 (file)
@@ -159,6 +159,7 @@ SOURCES += smartapi/agents/Agent.cpp \
         smartapi/model/PriceListSpecification.cpp \
         smartapi/model/DependentPriceSpecification.cpp \
         smartapi/model/TimeDependentPriceSpecification.cpp \
+        smartapi/model/LocationDependentPriceSpecification.cpp \
         smartapi/model/PropertyDependentPriceSpecification.cpp \
         smartapi/model/DurationDependentPriceSpecification.cpp \
         smartapi/model/CalculationMethod.cpp \
@@ -172,9 +173,9 @@ SOURCES += smartapi/agents/Agent.cpp \
         smartapi/model/ZoneTravelDurationDependentPriceSpecification.cpp \
         smartapi/model/DurationAtDistanceDependentPriceSpecification.cpp \
         smartapi/model/DurationAtZoneDependentPriceSpecification.cpp \
-    smartapi/model/TimeDependentPriceListSpecification.cpp \
-    smartapi/model/ObjectOperationDependentPriceSpecification.cpp \
-    smartapi/model/License.cpp
+        smartapi/model/TimeDependentPriceListSpecification.cpp \
+        smartapi/model/ObjectOperationDependentPriceSpecification.cpp \
+        smartapi/model/License.cpp
 
        
 HEADERS += smartapi/agents/Agent.h \
@@ -300,6 +301,7 @@ HEADERS += smartapi/agents/Agent.h \
         smartapi/model/DependentPriceSpecification.h \
         smartapi/model/TimeDependentPriceSpecification.h \
         smartapi/model/PropertyDependentPriceSpecification.h \
+        smartapi/model/LocationDependentPriceSpecification.h \
         smartapi/model/DurationDependentPriceSpecification.h \
         smartapi/model/Calculable.h \
         smartapi/model/CalculationMethod.h \
@@ -313,9 +315,9 @@ HEADERS += smartapi/agents/Agent.h \
         smartapi/model/ZoneTravelDurationDependentPriceSpecification.h \
         smartapi/model/DurationAtDistanceDependentPriceSpecification.h \
         smartapi/model/DurationAtZoneDependentPriceSpecification.h \
-    smartapi/model/TimeDependentPriceListSpecification.h \
-    smartapi/model/ObjectOperationDependentPriceSpecification.h \
-    smartapi/model/License.h
+        smartapi/model/TimeDependentPriceListSpecification.h \
+        smartapi/model/ObjectOperationDependentPriceSpecification.h \
+        smartapi/model/License.h
 
 
 DESTDIR = lib
index fc45d0aaa87c9d867c48b82b7ec8d9679f7af626..9c6b278c8e9abdc306d1c0c56c6833f2f88099a0 100644 (file)
@@ -257,6 +257,17 @@ void SearchAgent::ofId(QString searchString)
        mEntity->add(PROPERTY__ID, condition);
 }
 
+void SearchAgent::ofIds(QStringList searchStrings)
+{
+       for (int i = 0; i < searchStrings.length(); i++) {
+               if (searchStrings.at(i).length() > 0) {
+                       Condition* condition = new Condition();
+                       condition->addRegex("(?i)" + searchStrings.at(i));
+                       mEntity->add(PROPERTY__ID, condition);
+               }
+       }
+}
+
 void SearchAgent::ofDescription(QString searchString)
 {
        Condition* condition = new Condition();
index 7caa67e0bb09a545959c2b7dfe66417f6f9c9bc9..12dd1bf9e04910192b4b139a71aa1b69a0712639 100644 (file)
@@ -44,6 +44,7 @@ public:
        void ofName(QString searchString, bool exactMatch = false);
        void ofType(QString type);
        void ofId(QString searchString);
+       void ofIds(QStringList searchStrings);
        void ofDescription(QString searchString);
        void ofOutputCategory(QString category);
        void ofInputCategory(QString category);
index a988461c6e49c6092e4890a9801d48dc1056f135..ca28bc545d5c8eab9a27717435f71e61dd38557e 100644 (file)
@@ -68,6 +68,7 @@
 #include "smartapi/model/ZoneTravelDurationDependentPriceSpecification.h"
 #include "smartapi/model/DurationAtDistanceDependentPriceSpecification.h"
 #include "smartapi/model/DurationAtZoneDependentPriceSpecification.h"
+#include "smartapi/model/ObjectOperationDependentPriceSpecification.h"
 
 #include "smartapi/model/TemporalContext.h"
 #include "smartapi/model/TimeSeries.h"
@@ -196,6 +197,7 @@ public:
                if (type == RESOURCE__ZONETRAVELDURATIONDEPENDENTPRICESPECIFICATION) return new ZoneTravelDurationDependentPriceSpecification();
                if (type == RESOURCE__DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION) return new DurationAtDistanceDependentPriceSpecification();
                if (type == RESOURCE__DURATIONATZONEDEPENDENTPRICESPECIFICATION) return new DurationAtZoneDependentPriceSpecification();
+               if (type == RESOURCE__OBJECTOPERATIONDEPENDENTPRICESPECIFICATION) return new ObjectOperationDependentPriceSpecification();
 
                // qWarning() << "Classmapper could not find an object of type" << type;
                return NULL;
@@ -275,8 +277,9 @@ public:
                if (type == RESOURCE__ZONETRAVELDURATIONDEPENDENTPRICESPECIFICATION) return new ZoneTravelDurationDependentPriceSpecification((ZoneTravelDurationDependentPriceSpecification*)o);
                if (type == RESOURCE__DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION) return new DurationAtDistanceDependentPriceSpecification((DurationAtDistanceDependentPriceSpecification*)o);
                if (type == RESOURCE__DURATIONATZONEDEPENDENTPRICESPECIFICATION) return new DurationAtZoneDependentPriceSpecification((DurationAtZoneDependentPriceSpecification*)o);
+               if (type == RESOURCE__OBJECTOPERATIONDEPENDENTPRICESPECIFICATION) return new ObjectOperationDependentPriceSpecification((ObjectOperationDependentPriceSpecification*)o);
 
-               qWarning() << "Classmapper could not find the requested type of object.";
+               qWarning() << "Classmapper could not find the requested type of object:" << type;
                return NULL;
        }
        
index 5a3e9ae4805b01082c2d7783fc66a7ca0a005e9d..a644d710dedf88c31f7635c1745248b6841b8e03 100644 (file)
 #define PROPERTY__PAYMENTTERM          "http://smart-api.io/ontology/1.0/smartapi#paymentTerm"
 #define PROPERTY__PERCENTAGE           "http://smart-api.io/ontology/1.0/smartapi#percentage"
 #define PROPERTY__PERCENTAGEDISCOUNT           "http://smart-api.io/ontology/1.0/smartapi#percentageDiscount"
+#define PROPERTY__PERCENTAGEMARGIN             "http://smart-api.io/ontology/1.0/smartapi#percentageMargin"
 #define PROPERTY__PERCENTAGEMARKUP             "http://smart-api.io/ontology/1.0/smartapi#percentageMarkup"
 #define PROPERTY__PERSON               "http://smart-api.io/ontology/1.0/smartapi#person"
 #define PROPERTY__PHOTO                "http://www.w3.org/2006/vcard/ns#photo"
index 1c7f0a3473d9a613707b59bed6471062137f6189..fca6439f8fc579f1a3bace06de90606e9fa8dc4e 100644 (file)
 #define RESOURCE__DIOPTER              "http://data.nasa.gov/qudt/owl/unit#Diopter"
 #define RESOURCE__DIRECTDEBIT          "http://purl.org/goodrelations/v1#DirectDebit"
 #define RESOURCE__DIRECTION            "http://smart-api.io/ontology/1.0/smartapi#Direction"
+#define RESOURCE__DISCOUNT             "http://smart-api.io/ontology/1.0/smartapi#Discount"
 #define RESOURCE__DISCOVER             "http://purl.org/goodrelations/v1#Discover"
 #define RESOURCE__DISPOSE              "http://purl.org/goodrelations/v1#Dispose"
 #define RESOURCE__DISTANCEDEPENDENTPRICESPECIFICATION          "http://smart-api.io/ontology/1.0/smartapi#DistanceDependentPriceSpecification"
index 4c54874f99ec2afe9d428e02588935fef62ef632..56d0dbf61231913573d4174cb18dcf3e751d46ab 100644 (file)
@@ -25,8 +25,6 @@ public:
        void setCoordinates(Coordinates* c)                                             { add(PROPERTY__LOCATION, c); mCoordinates = c; }
        void setCoordinates(double lat, double lon)                             { setCoordinates(new Coordinates(lat, lon)); }
 
-       bool isTimeDependent() { return false; }
-
 private:
        Coordinates* mCoordinates;
 };
index 396751a7e3ec0d150200034f058b9089fa8d86c6..f602592d4602002d72a870bb4bf941eb9a803bd7 100644 (file)
@@ -3,7 +3,7 @@
 #include "smartapi/common/RESOURCE.h"
 
 DurationAtDistanceDependentPriceSpecification::DurationAtDistanceDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION);
        INIT_PROPERTY(mCoordinates);
@@ -21,7 +21,7 @@ DurationAtDistanceDependentPriceSpecification::DurationAtDistanceDependentPriceS
 }
 
 DurationAtDistanceDependentPriceSpecification::DurationAtDistanceDependentPriceSpecification(DurationAtDistanceDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
        SET_PROPERTY_REFERENCE(PROPERTY__LOCATION, mCoordinates, Coordinates)
        setType(RESOURCE__DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION);
index 8d25da4b6d2fc2bb2f7f59d642905d51b3a43441..c0f7eb837ce54c549585c7ea90251dc52efc8efd 100644 (file)
@@ -1,13 +1,13 @@
 #ifndef DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION_H
 #define DURATIONATDISTANCEDEPENDENTPRICESPECIFICATION_H
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 
 #include "smartapi/common/PROPERTY.h"
 #include "smartapi/model/Coordinates.h"
 
 
-class DurationAtDistanceDependentPriceSpecification : public DependentPriceSpecification
+class DurationAtDistanceDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 
 public:
@@ -25,8 +25,6 @@ public:
        void setCoordinates(Coordinates* c)                                             { add(PROPERTY__LOCATION, c); mCoordinates = c; }
        void setCoordinates(double lat, double lon)                             { setCoordinates(new Coordinates(lat, lon)); }
 
-       bool isTimeDependent() { return true; }
-
 private:
        Coordinates* mCoordinates;};
 
index 1b3c75bf98bf441c3e11f5163ec64ddf4e6eabd2..aa07a8260ed86d988131322ece91e50edbcb7e8d 100644 (file)
@@ -3,7 +3,7 @@
 #include "smartapi/common/RESOURCE.h"
 
 DurationAtZoneDependentPriceSpecification::DurationAtZoneDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__DURATIONATZONEDEPENDENTPRICESPECIFICATION);
 }
@@ -20,7 +20,7 @@ DurationAtZoneDependentPriceSpecification::DurationAtZoneDependentPriceSpecifica
 }
 
 DurationAtZoneDependentPriceSpecification::DurationAtZoneDependentPriceSpecification(DurationAtZoneDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
 }
 
index a97a64a611de119f4c2853d826b48e4cb62df249..93bf589584f17cd7b7c6c266ff8aa2eb8a1ad189 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef DURATIONATZONEDEPENDENTPRICESPECIFICATION_H
 #define DURATIONATZONEDEPENDENTPRICESPECIFICATION_H
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 
-class DurationAtZoneDependentPriceSpecification : public DependentPriceSpecification
+class DurationAtZoneDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 public:
        DurationAtZoneDependentPriceSpecification(QString identifierUri = QString());
@@ -15,8 +15,6 @@ public:
        Resource* serialize(Model* model);
        void parse(Statement* statement);
 
-       bool isTimeDependent() { return false; }
-
 };
 
 #endif // DURATIONATZONEDEPENDENTPRICESPECIFICATION_H
diff --git a/Common/C++/SmartAPI/smartapi/model/LocationDependentPriceSpecification.cpp b/Common/C++/SmartAPI/smartapi/model/LocationDependentPriceSpecification.cpp
new file mode 100644 (file)
index 0000000..89e5383
--- /dev/null
@@ -0,0 +1,14 @@
+#include "LocationDependentPriceSpecification.h"
+
+LocationDependentPriceSpecification::LocationDependentPriceSpecification(QString identifierUri) :
+       DependentPriceSpecification(identifierUri)
+{
+}
+
+LocationDependentPriceSpecification::LocationDependentPriceSpecification(DependentPriceSpecification* o) :
+       DependentPriceSpecification(o)
+{
+}
+
+LocationDependentPriceSpecification::~LocationDependentPriceSpecification()
+{}
diff --git a/Common/C++/SmartAPI/smartapi/model/LocationDependentPriceSpecification.h b/Common/C++/SmartAPI/smartapi/model/LocationDependentPriceSpecification.h
new file mode 100644 (file)
index 0000000..a4e6dd7
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef LOCATIONDEPENDENTPRICESPECIFICATION_H
+#define LOCATIONDEPENDENTPRICESPECIFICATION_H
+
+#include "smartapi/model/DependentPriceSpecification.h"
+
+class LocationDependentPriceSpecification : public DependentPriceSpecification
+{
+
+public:
+       LocationDependentPriceSpecification(QString identifierUri = QString());
+       LocationDependentPriceSpecification(DependentPriceSpecification* o);
+       ~LocationDependentPriceSpecification();
+
+       bool isTimeDependent() { return false; }
+
+private:
+
+};
+
+#endif // LOCATIONDEPENDENTPRICESPECIFICATION_H
index bbaad0e9e4f934b98328120a67225a5b845ad9bc..b6b71a5f76c94d3c6a8761aabd82323e3b53558b 100755 (executable)
@@ -14,6 +14,7 @@ PriceSpecification::PriceSpecification(QString identifierUri)
        INIT_PROPERTY(mVatPercentage)
        INIT_PROPERTY(mFixedMarkup)
        INIT_PROPERTY(mPercentageMarkup)
+       INIT_PROPERTY(mPercentageMargin)
        INIT_PROPERTY(mQuantity)
        INIT_PROPERTY(mUnit)
        INIT_PROPERTY(mSecondaryQuantity)
@@ -33,6 +34,7 @@ PriceSpecification::PriceSpecification(float price, QString unit, QString second
        INIT_PROPERTY(mVatPercentage)
        INIT_PROPERTY(mFixedMarkup)
        INIT_PROPERTY(mPercentageMarkup)
+       INIT_PROPERTY(mPercentageMargin)
        INIT_PROPERTY(mQuantity)
        INIT_PROPERTY(mUnit)
        INIT_PROPERTY(mSecondaryQuantity)
@@ -56,6 +58,7 @@ PriceSpecification::PriceSpecification(PriceSpecification* o) : GrObj(o)
        SET_PROPERTY_REFERENCE(PROPERTY__VATPERCENTAGE,mVatPercentage,Variant);
        SET_PROPERTY_REFERENCE(PROPERTY__FIXEDMARKUP,mFixedMarkup,Variant);
        SET_PROPERTY_REFERENCE(PROPERTY__PERCENTAGEMARKUP,mPercentageMarkup,Variant);
+       SET_PROPERTY_REFERENCE(PROPERTY__PERCENTAGEMARGIN,mPercentageMargin,Variant);
        SET_PROPERTY_REFERENCE(PROPERTY__QUANTITYKIND,mQuantity,Variant);
        SET_PROPERTY_REFERENCE(PROPERTY__UNIT,mUnit,Variant);
        SET_PROPERTY_REFERENCE(PROPERTY__SECONDARYQUANTITYKIND,mSecondaryQuantity,Variant);
@@ -90,6 +93,7 @@ void PriceSpecification::parse(Statement* statement)
        PARSE_PROPERTY(PROPERTY__VATPERCENTAGE, setVatPercentage, Variant)
        PARSE_PROPERTY(PROPERTY__FIXEDMARKUP, setFixedMarkup, Variant)
        PARSE_PROPERTY(PROPERTY__PERCENTAGEMARKUP, setPercentageMarkup, Variant)
+       PARSE_PROPERTY(PROPERTY__PERCENTAGEMARGIN, setPercentageMargin, Variant)
        PARSE_PROPERTY(PROPERTY__QUANTITYKIND, setQuantity, Variant)
        PARSE_PROPERTY(PROPERTY__UNIT, setUnit, Variant)
        PARSE_PROPERTY(PROPERTY__SECONDARYQUANTITYKIND, setSecondaryQuantity, Variant)
index 65b782cf8e8d1cb966dc2344b611e110f883fb00..8054671c333e2b784ebb5e7155ee26299d7e9643 100644 (file)
@@ -58,6 +58,11 @@ public:
        void setPercentageMarkup(double d)                                                      { setPercentageMarkup(new Variant(d)); }
        double getPercentageMarkup()                                                            { PROPERTYVAL(mPercentageMarkup, asDouble, 0); }
 
+       bool hasPercentageMargin()                                                                      { return mPercentageMargin != NULL; }
+       void setPercentageMargin(Variant* v)                                            { set(PROPERTY__PERCENTAGEMARGIN, v); mPercentageMargin = v; }
+       void setPercentageMargin(double d)                                                      { setPercentageMargin(new Variant(d)); }
+       double getPercentageMargin()                                                            { PROPERTYVAL(mPercentageMargin, asDouble, 0); }
+
        bool hasQuantity()                                                                                      { return mQuantity != NULL; }
        QString getQuantity()                                                                           { PROPERTYVAL(mQuantity, asString, QString()); }
        void setQuantity(Variant* quantity)                                             { set(PROPERTY__QUANTITYKIND, quantity); mQuantity = quantity; }
@@ -97,6 +102,7 @@ private:
        Variant* mVatPercentage;
        Variant* mFixedMarkup;
        Variant* mPercentageMarkup;
+       Variant* mPercentageMargin;
 };
 
 #endif // _PRICESPECIFICATION_H_
index 1ebb76ef01a1a7e1725d9df86511a5278ee3b53c..da559142ae7349a942cde4fb206d427e23b739fc 100644 (file)
@@ -5,7 +5,7 @@
 #include <QtDebug>
 
 TravelDistanceDependentPriceSpecification::TravelDistanceDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__TRAVELDISTANCEDEPENDENTPRICESPECIFICATION);
        INIT_PROPERTY(mCalculationMethod)
@@ -24,7 +24,7 @@ TravelDistanceDependentPriceSpecification::TravelDistanceDependentPriceSpecifica
 }
 
 TravelDistanceDependentPriceSpecification::TravelDistanceDependentPriceSpecification(TravelDistanceDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
        SET_PROPERTY_REFERENCE(PROPERTY__CALCULATIONMETHOD, mCalculationMethod, CalculationMethod)
        setType(RESOURCE__TRAVELDISTANCEDEPENDENTPRICESPECIFICATION);
index f36c2d93bf8cda00abbaeab6b5c565c2860041ae..7045a1adf4f313407b7f973bf09788708669f3d3 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef TRAVELDISTANCEDEPENDENTPRICESPECIFICATION_H
 #define TRAVELDISTANCEDEPENDENTPRICESPECIFICATION_H
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 #include "smartapi/model/CalculationMethod.h"
 
 #include "smartapi/common/RESOURCE.h"
 
-class TravelDistanceDependentPriceSpecification : public DependentPriceSpecification
+class TravelDistanceDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 public:
        TravelDistanceDependentPriceSpecification(QString identifierUri = QString());
@@ -29,8 +29,6 @@ public:
 
        double calculatePrice(double distance);
 
-       bool isTimeDependent() { return false; }
-
 private:
        CalculationMethod* mCalculationMethod;
 };
index 47acbf102bb8bd291b01bd3a43a00701a43ff5c7..96087f29291196a918de50a4311afac3e56cbc27 100644 (file)
@@ -3,13 +3,13 @@
 #include "smartapi/common/RESOURCE.h"
 
 TravelDistanceDurationDependentPriceSpecification::TravelDistanceDurationDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__TRAVELDISTANCEDURATIONDEPENDENTPRICESPECIFICATION);
 }
 
 TravelDistanceDurationDependentPriceSpecification::TravelDistanceDurationDependentPriceSpecification(QString unit, QString secondaryUnit, QString secondaryQuantity, QDateTime validFrom, QDateTime validThrough) :
-       TravelDistanceDurationDependentPriceSpecification()
+       LocationDependentPriceSpecification()
 {
        setQuantity(RESOURCE__CURRENCY);
        setUnit(unit);
@@ -20,7 +20,7 @@ TravelDistanceDurationDependentPriceSpecification::TravelDistanceDurationDepende
 }
 
 TravelDistanceDurationDependentPriceSpecification::TravelDistanceDurationDependentPriceSpecification(TravelDistanceDurationDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
 }
 
index 2660364aa73c0a29a7c0fd82d6ffc0034cd4168f..cb7da9559b701079bc0c80aaaeb6a7bb50dad2ac 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef TRAVELDISTANCEDURATIONDEPENDENTPRICESPECIFICATION_H
 #define TRAVELDISTANCEDURATIONDEPENDENTPRICESPECIFICATION_H
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 
-class TravelDistanceDurationDependentPriceSpecification : public DependentPriceSpecification
+class TravelDistanceDurationDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 public:
        TravelDistanceDurationDependentPriceSpecification(QString identifierUri = QString());
@@ -15,8 +15,6 @@ public:
        Resource* serialize(Model* model);
        void parse(Statement* statement);
 
-       bool isTimeDependent() { return true; }
-
 };
 
 #endif // TRAVELDISTANCEDURATIONDEPENDENTPRICESPECIFICATION_H
index 3d342fbd2bae3735820d488dedc8fd2288823488..2f8edd732e931f9338c3ee8ddcf6ebdfb9f2b168 100644 (file)
@@ -3,7 +3,7 @@
 #include "smartapi/common/RESOURCE.h"
 
 ZoneDependentPriceSpecification::ZoneDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__ZONEDEPENDENTPRICESPECIFICATION);
 }
@@ -20,7 +20,7 @@ ZoneDependentPriceSpecification::ZoneDependentPriceSpecification(QString unit, Q
 }
 
 ZoneDependentPriceSpecification::ZoneDependentPriceSpecification(ZoneDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
 }
 
index 3197c2216006f1c61c305a4dbe3545c0ab67049f..c643cab4b47e4a063914c3831f82785e302dab7c 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef ZONEDEPENDENTPRICESPECIFICATION_H
 #define ZONEDEPENDENTPRICESPECIFICATION_H
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 
-class ZoneDependentPriceSpecification : public DependentPriceSpecification
+class ZoneDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 public:
        ZoneDependentPriceSpecification(QString identifierUri = QString());
@@ -15,8 +15,6 @@ public:
        Resource* serialize(Model* model);
        void parse(Statement* statement);
 
-       bool isTimeDependent() { return false; }
-
 };
 
 #endif // ZONEDEPENDENTPRICESPECIFICATION_H
index aef163b1d6e379098d73580204089934177949e8..bcd32e4bdc594dc312897383357f1acbd5a8d89b 100644 (file)
@@ -5,7 +5,9 @@
 ZonePopulationDependentPriceSpecification::ZonePopulationDependentPriceSpecification(QString identifierUri) :
        DependentPriceSpecification(identifierUri)
 {
-       setType(RESOURCE__ZONETRAVELDEPENDENTPRICESPECIFICATION);
+       setType(RESOURCE__ZONEPOPULATIONDEPENDENTPRICESPECIFICATION);
+       INIT_PROPERTY(mCalculationMethod)
+       INIT_PROPERTY(mZone)
 }
 
 ZonePopulationDependentPriceSpecification::ZonePopulationDependentPriceSpecification(QString unit, QString secondaryUnit, QString secondaryQuantity, QDateTime validFrom, QDateTime validThrough) :
@@ -22,6 +24,9 @@ ZonePopulationDependentPriceSpecification::ZonePopulationDependentPriceSpecifica
 ZonePopulationDependentPriceSpecification::ZonePopulationDependentPriceSpecification(ZonePopulationDependentPriceSpecification* o) :
        DependentPriceSpecification(o)
 {
+       SET_PROPERTY_REFERENCE(PROPERTY__CALCULATIONMETHOD, mCalculationMethod, CalculationMethod)
+       SET_PROPERTY_REFERENCE(PROPERTY__ZONE, mZone, Zone)
+       setType(RESOURCE__ZONEPOPULATIONDEPENDENTPRICESPECIFICATION);
 }
 
 ZonePopulationDependentPriceSpecification::~ZonePopulationDependentPriceSpecification()
@@ -43,5 +48,21 @@ Resource* ZonePopulationDependentPriceSpecification::serialize(Model* model)
 void ZonePopulationDependentPriceSpecification::parse(Statement* statement)
 {
        INIT_PARSE(statement)
+       PARSE_PROPERTY(PROPERTY__CALCULATIONMETHOD, setCalculationMethod, CalculationMethod)
+       PARSE_PROPERTY(PROPERTY__ZONE, setZone, Zone)
        FINISH_PARSE(DependentPriceSpecification)
 }
+
+void ZonePopulationDependentPriceSpecification::setCalculationMethod(CalculationMethod* cm)
+{
+       addType(RESOURCE__LINEARPRICESPECIFICATION);
+       add(PROPERTY__CALCULATIONMETHOD, cm);
+       mCalculationMethod = cm;
+}
+
+void ZonePopulationDependentPriceSpecification::addCondition(Condition* condition)
+{
+       addType(RESOURCE__STEPPRICESPECIFICATION);
+       DependentPriceSpecification::addCondition(condition);
+}
+
index 14f556be6376e7c5d7e6f9fa1ed0161f5fc9a670..8e7df9dc48bc69253827174768d063b76965c2bd 100644 (file)
@@ -2,6 +2,10 @@
 #define ZONEPOPULATIONDEPENDENTPRICESPECIFICATION_H
 
 #include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/CalculationMethod.h"
+#include "smartapi/model/Zone.h"
+#include "smartapi/common/RESOURCE.h"
+
 
 class ZonePopulationDependentPriceSpecification : public DependentPriceSpecification
 {
@@ -15,8 +19,24 @@ public:
        Resource* serialize(Model* model);
        void parse(Statement* statement);
 
+       bool isStepPriceSpecification() { return hasType(RESOURCE__STEPPRICESPECIFICATION); }
+       bool isLinearPriceSpecification() { return hasType(RESOURCE__LINEARPRICESPECIFICATION); }
+
+       bool hasCalculationMethod()                                                                     { return (mCalculationMethod != NULL); }
+       CalculationMethod* getCalculationMethod()                                       { return mCalculationMethod; }
+       void setCalculationMethod(CalculationMethod* cm);
+       void addCondition(Condition* condition);
+
+       bool hasZone()                                                                                          { return (mZone != NULL); }
+       Zone* getZone()                                                                                         { return mZone; }
+       void setZone(Zone* z)                                                                           { add(PROPERTY__ZONE, z); mZone = z; }
+
        bool isTimeDependent() { return false; }
 
+private:
+       CalculationMethod* mCalculationMethod;
+       Zone* mZone;
+
 };
 
 #endif // ZONEPOPULATIONDEPENDENTPRICESPECIFICATION_H
index bb8a47e692020eab9e404953c7ed11801b1300cd..1e44bae98a131c00d40190bd956b92e517210bdc 100644 (file)
@@ -3,7 +3,7 @@
 #include "smartapi/common/RESOURCE.h"
 
 ZoneTravelDependentPriceSpecification::ZoneTravelDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__ZONETRAVELDEPENDENTPRICESPECIFICATION);
 }
@@ -20,7 +20,7 @@ ZoneTravelDependentPriceSpecification::ZoneTravelDependentPriceSpecification(QSt
 }
 
 ZoneTravelDependentPriceSpecification::ZoneTravelDependentPriceSpecification(ZoneTravelDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
 }
 
index 6debdd1219b368910429358c10b9331153859f19..83bca3923cf2f2bd6868232f7471ba73d533f5ec 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef ZONETRAVELDEPENDENTPRICESPECIFICATION_H
 #define ZONETRAVELDEPENDENTPRICESPECIFICATION_H
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 
-class ZoneTravelDependentPriceSpecification : public DependentPriceSpecification
+class ZoneTravelDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 public:
        ZoneTravelDependentPriceSpecification(QString identifierUri = QString());
@@ -14,9 +14,6 @@ public:
        virtual void clearReferences(QSet<GraphItem*>* trash);
        Resource* serialize(Model* model);
        void parse(Statement* statement);
-
-       bool isTimeDependent() { return false; }
-
 };
 
 #endif // ZONETRAVELDEPENDENTPRICESPECIFICATION_H
index 741b8a0e5b32f91b23391bf0230ff1d40401aead..850421d8d3e6f36052e554a0c5d98aaff5eb37b6 100644 (file)
@@ -3,7 +3,7 @@
 #include "smartapi/common/RESOURCE.h"
 
 ZoneTravelDurationDependentPriceSpecification::ZoneTravelDurationDependentPriceSpecification(QString identifierUri) :
-       DependentPriceSpecification(identifierUri)
+       LocationDependentPriceSpecification(identifierUri)
 {
        setType(RESOURCE__ZONETRAVELDURATIONDEPENDENTPRICESPECIFICATION);
 }
@@ -20,7 +20,7 @@ ZoneTravelDurationDependentPriceSpecification::ZoneTravelDurationDependentPriceS
 }
 
 ZoneTravelDurationDependentPriceSpecification::ZoneTravelDurationDependentPriceSpecification(ZoneTravelDurationDependentPriceSpecification* o) :
-       DependentPriceSpecification(o)
+       LocationDependentPriceSpecification(o)
 {
 }
 
index 6a5cfa68165def6d7e85c65499d9cff4aea29e82..17152362e00987926452fb586f05ad47dbd14026 100644 (file)
@@ -2,9 +2,9 @@
 #define ZONETRAVELDURATIONDEPENDENTPRICESPECIFICATION_H
 
 
-#include "smartapi/model/DependentPriceSpecification.h"
+#include "smartapi/model/LocationDependentPriceSpecification.h"
 
-class ZoneTravelDurationDependentPriceSpecification : public DependentPriceSpecification
+class ZoneTravelDurationDependentPriceSpecification : public LocationDependentPriceSpecification
 {
 public:
        ZoneTravelDurationDependentPriceSpecification(QString identifierUri = QString());
@@ -15,9 +15,6 @@ public:
        virtual void clearReferences(QSet<GraphItem*>* trash);
        Resource* serialize(Model* model);
        void parse(Statement* statement);
-
-       bool isTimeDependent() { return true; }
-
 };
 
 #endif // ZONETRAVELDURATIONDEPENDENTPRICESPECIFICATION_H