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{
44 std::map<std::string, std::string> attributeMap;
47 QueryGeneratorMode m_mode;
49 std::vector<std::string> m_queryVector;
53 std::vector<std::string> typeVector;
55 Api::Tizen::SortModePtr m_sortMode;
60 std::string m_currentType;
62 static const std::string STRING_MATCH_EXCACTLY;
63 static const std::string STRING_MATCH_CONTAINS;
64 static const std::string STRING_MATCH_STARTSWITH;
65 static const std::string STRING_MATCH_ENDSWITH;
66 static const std::string STRING_MATCH_CASESENSITIVE;
67 static const std::string STRING_WHERE;
68 static const std::string STRING_SUFFIX;
69 static const std::string STRING_DIRECTION;
71 static const int MESSAGE_TYPE_NOT_INITIALIZED;
74 MessageQueryGenerator();
75 MessageQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset);
76 virtual ~MessageQueryGenerator();
78 void visitPreComposite(Api::Tizen::FilterType& type, int depth);
79 void visitInComposite(Api::Tizen::FilterType& type, int depth);
80 void visitPostComposite(Api::Tizen::FilterType& type, int depth);
81 void visitAttribute(std::string& attrName,
82 Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
83 void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
85 std::string getQuery();
87 // bool containMailType();
88 // bool containType(int type);
93 void setMode(QueryGeneratorMode mode ){
97 QueryGeneratorMode getMode(){
101 void reset(QueryGeneratorMode mode);
104 virtual void setEmailAttributeMap();
105 virtual void setSmsMmsAttributeMap();
106 virtual std::string getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
107 virtual std::string getQueryPrefix();
108 virtual std::string getQuerySuffix();
109 virtual std::string getMessageDirectionString();
111 std::string convertToEmfAttrName(std::string attrName);
113 void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
116 std::string getMatchStartsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
117 std::string getMatchEndsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
118 std::string getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
120 std::string createTimeString(std::string& timeString);
121 std::string createFolderType(std::string& value);
122 std::string createPriorityTypeForEmail(std::string& value);
123 std::string createPriorityTypeForSmsMms(std::string& value);
124 std::string createDateTimeTypeForEmail(Api::Tizen::AnyPtr& value);
126 std::string createDateTimeTypeForSmsMms(Api::Tizen::AnyPtr& value);
128 std::string convertToTimeFormat(const std::string& timeString);
129 std::string convertBooleanStringToIntegerString(std::string& booleanString);
131 void initAttributeMap();
132 std::string getQueryFromVector();
134 int convertMessageType(std::string& stringType);
137 typedef DPL::SharedPtr<MessageQueryGenerator> MessageQueryGeneratorPtr;
138 } // namespace Platform
139 } // namespace WrtPlugins
141 #endif /* MESSAGEQUERYGENERATOR_H_ */