Set the disjunction flag to false, if it has no effect 84/142284/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 3 Aug 2017 08:37:58 +0000 (17:37 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 3 Aug 2017 08:37:58 +0000 (17:37 +0900)
Change-Id: I4594ecb69c620bfa3b45b6e906fdea75dccf38c2
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/client/JobManagerProxy.cpp
src/shared/JobContext.cpp
src/shared/JobContext.h

index 88ed6d2c77ae307f78175fb40d114f06d93f9cb7..1c1908800884cc8bb36ab9a5917c1dacf53efdb1 100644 (file)
@@ -37,6 +37,24 @@ int JobManagerProxy::addJob(JobInfo* jobInfo)
 {
        IF_FAIL_RETURN(jobInfo, E_PARAM);
 
+       // If there is only one requirement, "disjunction == true" is pointless.
+       if (jobInfo->getRequirements().size() <= 1)
+               jobInfo->setDisjunction(false);
+
+       // If a requirement has only one attribute, "disjunction == true" is pointless.
+       for (auto& req : jobInfo->getRequirements()) {
+               if (req->size() <= 1)
+                       req->setDisjunction(false);
+       }
+
+       // If a trigger has only one attribute, "disjunction == true" is pointless.
+       if (jobInfo->getType() == JobInfo::Type::ON_DEMAND) {
+               for (auto& trg : static_cast<OnDemandJobInfo*>(jobInfo)->getTriggers()) {
+                       if (trg->size() <= 1)
+                               trg->setDisjunction(false);
+               }
+       }
+
        std::string serialized = jobInfo->serialize();
        GVariant* param = g_variant_new("(s)", serialized.c_str());
        GVariant* result = NULL;
index 6442b1cccbc1ba462bfd71f9e290a7f8a39050a9..ac135fa009fdae66a1aa14486eb1ef86df42cff2 100644 (file)
@@ -78,6 +78,11 @@ const std::string& JobContext::getUri() const
        return __uri;
 }
 
+unsigned int JobContext::size() const
+{
+       return __attributes.size();
+}
+
 Attribute* JobContext::getAttribute(const std::string& attrName)
 {
        for (auto& attr : __attributes) {
index 09dfa61755b796843c1bf2c23c599e2440aa1851..41f99ce20b91e9b7774bf089277f73c6783f2d8f 100644 (file)
@@ -41,6 +41,7 @@ namespace ctx {
                virtual JobContext::Type getType() const = 0;
 
                const std::string& getUri() const;
+               unsigned int size() const;
                Attribute* getAttribute(const std::string& attrName);
 
                bool prepareAttributeInt(const std::string& attrName);