2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * MessageQueryGenerator.h
19 * Created on: 2011. 10. 28.
23 #ifndef MESSAGEQUERYGENERATOR_H_
24 #define MESSAGEQUERYGENERATOR_H_
26 #include <API/Filter/IFilterVisitor.h>
27 #include <API/Filter/SortMode.h>
35 class MessageQueryGenerator: public TizenApis::Api::Tizen::IFilterVisitor{
38 enum QueryGeneratorMode{
45 std::map<std::string, std::string> attributeMap;
48 QueryGeneratorMode m_mode;
50 std::string m_orderLimit;
51 std::vector<std::string> m_queryVector;
56 std::vector<std::string> typeVector;
58 Api::Tizen::SortModePtr m_sortMode;
63 std::string m_currentType;
65 static const std::string STRING_MATCH_EXACTLY;
66 static const std::string STRING_MATCH_CONTAINS;
67 static const std::string STRING_MATCH_STARTSWITH;
68 static const std::string STRING_MATCH_ENDSWITH;
69 static const std::string STRING_MATCH_CASESENSITIVE;
70 static const std::string STRING_WHERE;
71 static const std::string STRING_SUFFIX;
72 static const std::string STRING_DIRECTION;
74 static const int MESSAGE_TYPE_NOT_INITIALIZED;
77 MessageQueryGenerator();
78 MessageQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset);
79 MessageQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type);
80 virtual ~MessageQueryGenerator();
82 void visitPreComposite(Api::Tizen::FilterType& type, int depth);
83 void visitInComposite(Api::Tizen::FilterType& type, int depth);
84 void visitPostComposite(Api::Tizen::FilterType& type, int depth);
85 void visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
86 Api::Tizen::AnyPtr& matchValue, int depth);
87 void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
89 std::string getQuery();
90 std::string getOrderLimit();
92 // bool containMailType();
93 // bool containType(int type);
98 void setMode(QueryGeneratorMode mode ){
102 QueryGeneratorMode getMode(){
106 int getServiceType(){
107 return m_serviceType;
110 void reset(QueryGeneratorMode mode);
113 virtual void setEmailAttributeMap();
114 virtual void setSmsMmsAttributeMap();
115 virtual std::string getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
116 virtual std::string getQueryPrefix();
117 virtual std::string getQuerySuffix();
118 virtual std::string getMessageDirectionString();
120 std::string convertToEmfAttrName(std::string attrName);
122 void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
123 std::string convertMessageTypeToString(std::string& stringType);
126 std::string getMatchStartsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
127 std::string getMatchEndsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
128 std::string getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
130 std::string createTimeString(std::string& timeString);
131 std::string createFolderType(std::string& value);
132 std::string createPriorityTypeForEmail(std::string& value);
133 std::string createPriorityTypeForSmsMms(std::string& value);
134 std::string createDateTimeTypeForEmail(Api::Tizen::AnyPtr& value);
136 std::string createDateTimeTypeForSmsMms(Api::Tizen::AnyPtr& value);
137 std::string createDateTimeTypeForSmsMms(std::string& timeString);
139 std::string convertToTimeFormat(const std::string& timeString);
140 std::string convertBooleanStringToIntegerString(std::string& booleanString);
141 std::string toDateDbStr(const std::tm &date) const;
143 void initAttributeMap();
144 std::string getQueryFromVector();
146 int convertMessageType(std::string& stringType);
149 typedef DPL::SharedPtr<MessageQueryGenerator> MessageQueryGeneratorPtr;
150 } // namespace Platform
151 } // namespace WrtPlugins
153 #endif /* MESSAGEQUERYGENERATOR_H_ */