first development for the export filter
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / taxon / tmp / LogicFilter.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.persistence.dao.taxon.tmp;
11
12 import java.util.UUID;
13
14 import eu.etaxonomy.cdm.model.common.CdmBase;
15 import eu.etaxonomy.cdm.model.common.ITreeNode;
16
17 /**
18 * Preliminary class which represents a filter for an export on a CdmBase object, combined
19 * with a logical operation.
20 * Added to an existing filter it may e.g. allow operations like "filter1 or filter(TaxonNode:123)"
21 * It includes the logical operators as enums.
22 *
23 * @author a.mueller
24 *
25 */
26 public class LogicFilter<T extends CdmBase> {
27
28 public enum Op{
29 OR, AND, NOT;
30 // OR(" OR "), AND(" AND "), NOT(" NOT ");
31 // String str;
32 //
33 // private Op(String opStr){
34 // str = opStr;
35 // }
36 }
37
38 private static final Op defaultOperator = Op.OR;
39
40 private Op operator = defaultOperator;
41
42 private UUID uuid;
43 private String treeIndex;
44
45
46
47 public LogicFilter(T cdmBase){
48 this(cdmBase, defaultOperator);
49 }
50
51 public LogicFilter(T cdmBase, Op operator){
52 if (cdmBase == null){
53 throw new IllegalArgumentException("Null object not allowed as filter criteria");
54 }
55 if (operator == null){
56 operator = defaultOperator;
57 }
58
59 this.uuid = cdmBase.getUuid();
60 this.operator = operator;
61 CdmBase cdmBase2 = CdmBase.deproxy(cdmBase, CdmBase.class);
62 if (cdmBase2 instanceof ITreeNode){
63 this.treeIndex = ((ITreeNode<?>)cdmBase2).treeIndex();
64 }
65 }
66
67 public Op getOperator() {
68 return operator;
69 }
70
71 public UUID getUuid() {
72 return uuid;
73 }
74
75 public String getTreeIndex() {
76 return treeIndex;
77 }
78
79 }