001: /*
002: * Copyright 2007 Luigi Dell'Aquila (luigi.dellaquila@assetdata.it)
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.romaframework.core.domain.query;
017:
018: import java.util.Set;
019:
020: import org.romaframework.aspect.core.annotation.AnnotationConstants;
021: import org.romaframework.aspect.core.annotation.CoreClass;
022: import org.romaframework.aspect.persistence.QueryByFilter;
023: import org.romaframework.aspect.view.ViewConstants;
024: import org.romaframework.aspect.view.annotation.ViewField;
025: import org.romaframework.core.command.CommandContext;
026: import org.romaframework.core.config.Refreshable;
027:
028: @CoreClass(orderFields="fieldName operators fieldValue fromContext")
029: public class VisualQueryFilter {
030:
031: private Refreshable parent;
032: private String fieldName;
033:
034: private CommandContext context = new CommandContext();
035:
036: @ViewField(visible=AnnotationConstants.FALSE)
037: private String operator;
038: @ViewField(render=ViewConstants.RENDER_SELECT,selectionField="operator")
039: private String[] operators = { QueryByFilter.FIELD_EQUALS,
040: QueryByFilter.FIELD_MAJOR,
041: QueryByFilter.FIELD_MAJOR_EQUALS,
042: QueryByFilter.FIELD_MINOR,
043: QueryByFilter.FIELD_MINOR_EQUALS,
044: QueryByFilter.FIELD_NOT_EQUALS, QueryByFilter.FIELD_LIKE };
045:
046: private Object fieldValue;
047:
048: public VisualQueryFilter(CommandContext context, Refreshable parent) {
049: this .parent = parent;
050: if (context != null)
051: this .context = context;
052: }
053:
054: public String getFieldName() {
055: return fieldName;
056: }
057:
058: public void setFieldName(String fieldName) {
059: this .fieldName = fieldName;
060: }
061:
062: public String getOperator() {
063: return operator;
064: }
065:
066: public void setOperator(String operator) {
067: this .operator = operator;
068: }
069:
070: public Object getFieldValue() {
071: return fieldValue;
072: }
073:
074: public void setFieldValue(Object fieldValue) {
075: this .fieldValue = fieldValue;
076: }
077:
078: public String[] getOperators() {
079: return operators;
080: }
081:
082: public void setOperators(String[] operators) {
083: this .operators = operators;
084: }
085:
086: @ViewField(render=ViewConstants.RENDER_SELECT,selectionField="fromContextSelection")
087: public Set<String> getFromContext() {
088: return context.getParameters().keySet();
089: }
090:
091: public void setFromContextSelection(Object[] selection) {
092: if (selection != null && selection.length > 0)
093: setFieldValue(VisualQueryComposer.CONTEXT_MARKER
094: + selection[0]);
095: parent.refresh();
096: }
097:
098: @ViewField(visible=AnnotationConstants.FALSE)
099: public Object[] getFromContextSelection() {
100: return null;
101: }
102: }
|