=== added directory 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common' === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Property.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Property.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Property.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,175 @@ +package org.hisp.dhis.dxf2.common; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.lang.reflect.Method; + +/** + * @author Morten Olav Hansen + */ +public class Property +{ + private String name; + + private String description; + + private String xmlName; + + private boolean xmlAttribute; + + private String xmlCollectionName; + + private Class clazz; + + private Method method; + + private boolean collection; + + private boolean identifiableObject; + + private Property( Method method ) + { + this.method = method; + } + + @JsonProperty + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; + } + + @JsonProperty + public String getDescription() + { + return description; + } + + public void setDescription( String description ) + { + this.description = description; + } + + @JsonProperty + public String getXmlName() + { + return xmlName; + } + + public void setXmlName( String xmlName ) + { + this.xmlName = xmlName; + } + + @JsonProperty + public boolean isXmlAttribute() + { + return xmlAttribute; + } + + public void setXmlAttribute( boolean xmlAttribute ) + { + this.xmlAttribute = xmlAttribute; + } + + @JsonProperty + public String getXmlCollectionName() + { + return xmlCollectionName; + } + + public void setXmlCollectionName( String xmlCollectionName ) + { + this.xmlCollectionName = xmlCollectionName; + } + + @JsonProperty + public Class getClazz() + { + return clazz; + } + + public void setClazz( Class clazz ) + { + this.clazz = clazz; + } + + public Method getMethod() + { + return method; + } + + public void setMethod( Method method ) + { + this.method = method; + } + + @JsonProperty + public boolean isCollection() + { + return collection; + } + + public void setCollection( boolean collection ) + { + this.collection = collection; + } + + @JsonProperty + public boolean isIdentifiableObject() + { + return identifiableObject; + } + + public void setIdentifiableObject( boolean identifiableObject ) + { + this.identifiableObject = identifiableObject; + } + + @Override public String toString() + { + return "PropertyDescriptor{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", xmlName='" + xmlName + '\'' + + ", xmlAttribute=" + xmlAttribute + + ", xmlCollectionName='" + xmlCollectionName + '\'' + + ", clazz=" + clazz + + ", method=" + method + + ", collection=" + collection + + ", identifiableObject=" + identifiableObject + + '}'; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Schema.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Schema.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/Schema.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,153 @@ +package org.hisp.dhis.dxf2.common; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import com.google.common.collect.Lists; +import org.hisp.dhis.common.DxfNamespaces; + +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +@JacksonXmlRootElement( localName = "schema", namespace = DxfNamespaces.DXF_2_0 ) +public class Schema +{ + private Class klass; + + private String singular; + + private String plural; + + private boolean importable; + + private boolean exportable; + + private boolean deletable; + + private List properties = Lists.newArrayList(); + + public Schema() + { + } + + public Schema( Class klass, String singular, String plural, boolean importable, boolean exportable, boolean deletable ) + { + this.klass = klass; + this.singular = singular; + this.plural = plural; + this.importable = importable; + this.exportable = exportable; + this.deletable = deletable; + } + + @JsonProperty + @JacksonXmlProperty( isAttribute = true, namespace = DxfNamespaces.DXF_2_0 ) + public Class getKlass() + { + return klass; + } + + public void setKlass( Class klass ) + { + this.klass = klass; + } + + @JsonProperty + public String getSingular() + { + return singular; + } + + public void setSingular( String singular ) + { + this.singular = singular; + } + + @JsonProperty + public String getPlural() + { + return plural; + } + + public void setPlural( String plural ) + { + this.plural = plural; + } + + @JsonProperty + public boolean isImportable() + { + return importable; + } + + public void setImportable( boolean importable ) + { + this.importable = importable; + } + + @JsonProperty + public boolean isExportable() + { + return exportable; + } + + public void setExportable( boolean exportable ) + { + this.exportable = exportable; + } + + @JsonProperty + public boolean isDeletable() + { + return deletable; + } + + public void setDeletable( boolean deletable ) + { + this.deletable = deletable; + } + + @JsonProperty + @JacksonXmlElementWrapper( localName = "properties", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "property", namespace = DxfNamespaces.DXF_2_0 ) + public List getProperties() + { + return properties; + } + + public void setProperties( List properties ) + { + this.properties = properties; + } +} === added directory 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops' === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/EmptyCollectionOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/EmptyCollectionOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/EmptyCollectionOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,69 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; + +/** + * @author Morten Olav Hansen + */ +public class EmptyCollectionOp extends Op +{ + @Override + public boolean wantValue() + { + return false; + } + + @Override + public OpStatus evaluate( Object object ) + { + if ( object == null ) + { + // TODO: ignore or include here? + return OpStatus.IGNORE; + } + + if ( Collection.class.isInstance( object ) ) + { + Collection c = (Collection) object; + + if ( c.isEmpty() ) + { + return OpStatus.INCLUDE; + } + else + { + return OpStatus.EXCLUDE; + } + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/EqOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/EqOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/EqOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,99 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; +import java.util.Date; + +/** + * @author Morten Olav Hansen + */ +public class EqOp extends Op +{ + @Override + public OpStatus evaluate( Object object ) + { + if ( getValue() == null || object == null ) + { + return OpStatus.IGNORE; + } + + if ( String.class.isInstance( object ) ) + { + String s1 = getValue( String.class ); + String s2 = (String) object; + + return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Boolean.class.isInstance( object ) ) + { + Boolean s1 = getValue( Boolean.class ); + Boolean s2 = (Boolean) object; + + return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Integer.class.isInstance( object ) ) + { + Integer s1 = getValue( Integer.class ); + Integer s2 = (Integer) object; + + return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Float.class.isInstance( object ) ) + { + Float s1 = getValue( Float.class ); + Float s2 = (Float) object; + + return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Collection.class.isInstance( object ) ) + { + Collection collection = (Collection) object; + Integer size = getValue( Integer.class ); + + if ( size != null && collection.size() == size ) + { + return OpStatus.INCLUDE; + } + else + { + return OpStatus.EXCLUDE; + } + } + else if ( Date.class.isInstance( object ) ) + { + Date s1 = getValue( Date.class ); + Date s2 = (Date) object; + + return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/FilterOps.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/FilterOps.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/FilterOps.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,73 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import java.util.List; +import java.util.Map; + +/** +* @author Morten Olav Hansen +*/ +public class FilterOps +{ + private Map> filters = Maps.newHashMap(); + + FilterOps() + { + } + + public void addFilter( String opStr, Op op ) + { + if ( !filters.containsKey( opStr ) ) + { + filters.put( opStr, Lists.newArrayList() ); + } + + filters.get( opStr ).add( op ); + } + + public Map> getFilters() + { + return filters; + } + + public void setFilters( Map> filters ) + { + this.filters = filters; + } + + @Override + public String toString() + { + return filters.toString(); + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/Filters.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/Filters.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/Filters.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,154 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.google.common.collect.Maps; + +import java.util.Map; + +/** +* @author Morten Olav Hansen +*/ +public class Filters +{ + private Map filters = Maps.newHashMap(); + + public Filters() + { + } + + public void addFilter( String path, String operator, String value ) + { + FilterOps filterOps = createPath( path ); + + if ( filterOps == null ) + { + return; + } + + if ( OpFactory.canCreate( operator ) ) + { + Op op = OpFactory.create( operator ); + + if ( op.wantValue() ) + { + if ( value == null ) + { + return; + } + + op.setValue( value ); + } + + filterOps.addFilter( operator, op ); + } + } + + @SuppressWarnings( "unchecked" ) + private FilterOps createPath( String path ) + { + if ( !path.contains( "." ) ) + { + if ( !filters.containsKey( path ) ) + { + filters.put( path, new FilterOps() ); + } + + return (FilterOps) filters.get( path ); + } + + String[] split = path.split( "\\." ); + + Map c = filters; + + for ( int i = 0; i < split.length; i++ ) + { + boolean last = (i == (split.length - 1)); + + if ( c.containsKey( split[i] ) ) + { + if ( FilterOps.class.isInstance( c.get( split[i] ) ) ) + { + if ( last ) + { + return (FilterOps) c.get( split[i] ); + } + else + { + FilterOps self = (FilterOps) c.get( split[i] ); + Map map = Maps.newHashMap(); + map.put( "__self__", self ); + + c.put( split[i], map ); + c = map; + } + } + else + { + c = (Map) c.get( split[i] ); + } + } + else + { + if ( last ) + { + FilterOps filterOps = new FilterOps(); + c.put( split[i], filterOps ); + return filterOps; + } + else + { + Map map = Maps.newHashMap(); + c.put( split[i], map ); + c = map; + } + } + } + + return null; + } + + public Map getFilters() + { + return filters; + } + + public void setFilters( Map filters ) + { + this.filters = filters; + } + + @Override + public String toString() + { + return "Filters{" + + "filters=" + filters + + '}'; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/GtOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/GtOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/GtOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,85 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; +import java.util.Date; + +/** + * @author Morten Olav Hansen + */ +public class GtOp extends Op +{ + @Override + public OpStatus evaluate( Object object ) + { + if ( getValue() == null || object == null ) + { + return OpStatus.IGNORE; + } + + if ( Integer.class.isInstance( object ) ) + { + Integer s1 = getValue( Integer.class ); + Integer s2 = (Integer) object; + + return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Float.class.isInstance( object ) ) + { + Float s1 = getValue( Float.class ); + Float s2 = (Float) object; + + return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Collection.class.isInstance( object ) ) + { + Collection collection = (Collection) object; + Integer size = getValue( Integer.class ); + + if ( size != null && collection.size() > size ) + { + return OpStatus.INCLUDE; + } + else + { + return OpStatus.EXCLUDE; + } + } + else if ( Date.class.isInstance( object ) ) + { + Date s1 = getValue( Date.class ); + Date s2 = (Date) object; + + return (s1 != null && s2.after( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/GteOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/GteOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/GteOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,85 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; +import java.util.Date; + +/** + * @author Morten Olav Hansen + */ +public class GteOp extends Op +{ + @Override + public OpStatus evaluate( Object object ) + { + if ( getValue() == null || object == null ) + { + return OpStatus.IGNORE; + } + + if ( Integer.class.isInstance( object ) ) + { + Integer s1 = getValue( Integer.class ); + Integer s2 = (Integer) object; + + return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Float.class.isInstance( object ) ) + { + Float s1 = getValue( Float.class ); + Float s2 = (Float) object; + + return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Collection.class.isInstance( object ) ) + { + Collection collection = (Collection) object; + Integer size = getValue( Integer.class ); + + if ( size != null && collection.size() >= size ) + { + return OpStatus.INCLUDE; + } + else + { + return OpStatus.EXCLUDE; + } + } + else if ( Date.class.isInstance( object ) ) + { + Date s1 = getValue( Date.class ); + Date s2 = (Date) object; + + return (s1 != null && (s2.after( s1 ) || s2.equals( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LikeOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LikeOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LikeOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,54 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** +* @author Morten Olav Hansen +*/ +public class LikeOp extends Op +{ + @Override + public OpStatus evaluate( Object object ) + { + if ( getValue() == null || object == null ) + { + return OpStatus.IGNORE; + } + + if ( String.class.isInstance( object ) ) + { + String s1 = getValue( String.class ); + String s2 = (String) object; + + return (s1 != null && s2.toLowerCase().contains( s1.toLowerCase() )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LtOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LtOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LtOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,85 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; +import java.util.Date; + +/** + * @author Morten Olav Hansen + */ +public class LtOp extends Op +{ + @Override + public OpStatus evaluate( Object object ) + { + if ( getValue() == null || object == null ) + { + return OpStatus.IGNORE; + } + + if ( Integer.class.isInstance( object ) ) + { + Integer s1 = getValue( Integer.class ); + Integer s2 = (Integer) object; + + return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Float.class.isInstance( object ) ) + { + Float s1 = getValue( Float.class ); + Float s2 = (Float) object; + + return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Collection.class.isInstance( object ) ) + { + Collection collection = (Collection) object; + Integer size = getValue( Integer.class ); + + if ( size != null && collection.size() < size ) + { + return OpStatus.INCLUDE; + } + else + { + return OpStatus.EXCLUDE; + } + } + else if ( Date.class.isInstance( object ) ) + { + Date s1 = getValue( Date.class ); + Date s2 = (Date) object; + + return (s1 != null && (s2.before( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LteOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LteOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/LteOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,85 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; +import java.util.Date; + +/** + * @author Morten Olav Hansen + */ +public class LteOp extends Op +{ + @Override + public OpStatus evaluate( Object object ) + { + if ( getValue() == null || object == null ) + { + return OpStatus.IGNORE; + } + + if ( Integer.class.isInstance( object ) ) + { + Integer s1 = getValue( Integer.class ); + Integer s2 = (Integer) object; + + return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Float.class.isInstance( object ) ) + { + Float s1 = getValue( Float.class ); + Float s2 = (Float) object; + + return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + else if ( Collection.class.isInstance( object ) ) + { + Collection collection = (Collection) object; + Integer size = getValue( Integer.class ); + + if ( size != null && collection.size() <= size ) + { + return OpStatus.INCLUDE; + } + else + { + return OpStatus.EXCLUDE; + } + } + else if ( Date.class.isInstance( object ) ) + { + Date s1 = getValue( Date.class ); + Date s2 = (Date) object; + + return (s1 != null && (s2.before( s1 ) || s2.equals( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/NeqOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/NeqOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/NeqOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,55 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** +* @author Morten Olav Hansen +*/ +public class NeqOp extends Op +{ + private Op op = OpFactory.create( "eq" ); + + @Override + public OpStatus evaluate( Object object ) + { + op.setValue( getValue() ); + OpStatus status = op.evaluate( object ); + + // switch status from EqOp + switch ( status ) + { + case INCLUDE: + return OpStatus.EXCLUDE; + case EXCLUDE: + return OpStatus.INCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/NullOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/NullOp.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/NullOp.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,52 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** +* @author Morten Olav Hansen +*/ +public class NullOp extends Op +{ + @Override + public boolean wantValue() + { + return false; + } + + @Override + public OpStatus evaluate( Object object ) + { + if ( object == null ) + { + return OpStatus.INCLUDE; + } + + return OpStatus.IGNORE; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/Op.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/Op.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/Op.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,123 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @author Morten Olav Hansen + */ +public abstract class Op +{ + private String value; + + private static SimpleDateFormat[] simpleDateFormats = new SimpleDateFormat[]{ + new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ" ), + new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" ), + new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm" ), + new SimpleDateFormat( "yyyy-MM-dd'T'HH" ), + new SimpleDateFormat( "yyyyMMdd" ), + new SimpleDateFormat( "yyyyMM" ), + new SimpleDateFormat( "yyyy" ) + }; + + public boolean wantValue() + { + return true; + } + + public void setValue( String value ) + { + this.value = value; + } + + public String getValue() + { + return value; + } + + @SuppressWarnings( "unchecked" ) + public T getValue( Class klass ) + { + if ( klass.isInstance( value ) ) + { + return (T) value; + } + + if ( Boolean.class.isAssignableFrom( klass ) ) + { + try + { + return (T) Boolean.valueOf( value ); + } + catch ( Exception ignored ) + { + } + } + else if ( Integer.class.isAssignableFrom( klass ) ) + { + try + { + return (T) Integer.valueOf( value ); + } + catch ( Exception ignored ) + { + } + } + else if ( Float.class.isAssignableFrom( klass ) ) + { + try + { + return (T) Float.valueOf( value ); + } + catch ( Exception ignored ) + { + } + } + else if ( Date.class.isAssignableFrom( klass ) ) + { + for ( SimpleDateFormat simpleDateFormat : simpleDateFormats ) + { + try + { + return (T) simpleDateFormat.parse( value ); + } + catch ( ParseException ignored ) + { + } + } + } + + return null; + } + + public abstract OpStatus evaluate( Object object ); +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/OpFactory.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/OpFactory.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/OpFactory.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,82 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import com.google.common.collect.Maps; + +import java.util.Map; + +/** + * @author Morten Olav Hansen + */ +public class OpFactory +{ + protected static Map> register = Maps.newHashMap(); + + static + { + register( "eq", EqOp.class ); + register( "neq", NeqOp.class ); + register( "like", LikeOp.class ); + register( "gt", GtOp.class ); + register( "gte", GteOp.class ); + register( "lt", LtOp.class ); + register( "lte", LteOp.class ); + register( "null", NullOp.class ); + register( "empty", EmptyCollectionOp.class ); + } + + public static void register( String type, Class opClass ) + { + register.put( type.toLowerCase(), opClass ); + } + + public static boolean canCreate( String type ) + { + return register.containsKey( type.toLowerCase() ); + } + + public static Op create( String type ) + { + Class opClass = register.get( type.toLowerCase() ); + + try + { + return opClass.newInstance(); + } + catch ( InstantiationException ignored ) + { + } + catch ( IllegalAccessException ignored ) + { + } + + return null; + } +} === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/OpStatus.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/OpStatus.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/common/ops/OpStatus.java 2014-03-13 14:27:16 +0000 @@ -0,0 +1,37 @@ +package org.hisp.dhis.dxf2.common.ops; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** +* @author Morten Olav Hansen +*/ +public enum OpStatus +{ + INCLUDE, EXCLUDE, IGNORE +} === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java 2014-03-12 17:30:37 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java 2014-03-13 14:27:16 +0000 @@ -651,7 +651,8 @@ this.identifiableObject = identifiableObject; } - @Override public String toString() + @Override + public String toString() { return "PropertyDescriptor{" + "name='" + name + '\'' + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java 2014-03-12 17:30:37 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java 2014-03-13 14:27:16 +0000 @@ -34,9 +34,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.api.controller.WebMetaData; -import org.hisp.dhis.api.utils.ops.FilterOps; -import org.hisp.dhis.api.utils.ops.Filters; -import org.hisp.dhis.api.utils.ops.Op; +import org.hisp.dhis.dxf2.common.ops.FilterOps; +import org.hisp.dhis.dxf2.common.ops.Filters; +import org.hisp.dhis.dxf2.common.ops.Op; import org.hisp.dhis.common.DimensionalObject; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.Pager; === removed directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops' === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java 2014-03-12 08:16:09 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java 1970-01-01 00:00:00 +0000 @@ -1,69 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; - -/** - * @author Morten Olav Hansen - */ -public class EmptyCollectionOp extends Op -{ - @Override - public boolean wantValue() - { - return false; - } - - @Override - public OpStatus evaluate( Object object ) - { - if ( object == null ) - { - // TODO: ignore or include here? - return OpStatus.IGNORE; - } - - if ( Collection.class.isInstance( object ) ) - { - Collection c = (Collection) object; - - if ( c.isEmpty() ) - { - return OpStatus.INCLUDE; - } - else - { - return OpStatus.EXCLUDE; - } - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java 2014-03-12 08:32:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java 1970-01-01 00:00:00 +0000 @@ -1,99 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -public class EqOp extends Op -{ - @Override - public OpStatus evaluate( Object object ) - { - if ( getValue() == null || object == null ) - { - return OpStatus.IGNORE; - } - - if ( String.class.isInstance( object ) ) - { - String s1 = getValue( String.class ); - String s2 = (String) object; - - return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Boolean.class.isInstance( object ) ) - { - Boolean s1 = getValue( Boolean.class ); - Boolean s2 = (Boolean) object; - - return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Integer.class.isInstance( object ) ) - { - Integer s1 = getValue( Integer.class ); - Integer s2 = (Integer) object; - - return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Float.class.isInstance( object ) ) - { - Float s1 = getValue( Float.class ); - Float s2 = (Float) object; - - return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Collection.class.isInstance( object ) ) - { - Collection collection = (Collection) object; - Integer size = getValue( Integer.class ); - - if ( size != null && collection.size() == size ) - { - return OpStatus.INCLUDE; - } - else - { - return OpStatus.EXCLUDE; - } - } - else if ( Date.class.isInstance( object ) ) - { - Date s1 = getValue( Date.class ); - Date s2 = (Date) object; - - return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/FilterOps.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/FilterOps.java 2014-03-10 04:51:30 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/FilterOps.java 1970-01-01 00:00:00 +0000 @@ -1,74 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.hisp.dhis.api.utils.ops.Op; - -import java.util.List; -import java.util.Map; - -/** -* @author Morten Olav Hansen -*/ -public class FilterOps -{ - private Map> filters = Maps.newHashMap(); - - FilterOps() - { - } - - public void addFilter( String opStr, Op op ) - { - if ( !filters.containsKey( opStr ) ) - { - filters.put( opStr, Lists.newArrayList() ); - } - - filters.get( opStr ).add( op ); - } - - public Map> getFilters() - { - return filters; - } - - public void setFilters( Map> filters ) - { - this.filters = filters; - } - - @Override - public String toString() - { - return filters.toString(); - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java 2014-03-12 08:16:09 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java 1970-01-01 00:00:00 +0000 @@ -1,154 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.google.common.collect.Maps; - -import java.util.Map; - -/** -* @author Morten Olav Hansen -*/ -public class Filters -{ - private Map filters = Maps.newHashMap(); - - public Filters() - { - } - - public void addFilter( String path, String operator, String value ) - { - FilterOps filterOps = createPath( path ); - - if ( filterOps == null ) - { - return; - } - - if ( OpFactory.canCreate( operator ) ) - { - Op op = OpFactory.create( operator ); - - if ( op.wantValue() ) - { - if ( value == null ) - { - return; - } - - op.setValue( value ); - } - - filterOps.addFilter( operator, op ); - } - } - - @SuppressWarnings( "unchecked" ) - private FilterOps createPath( String path ) - { - if ( !path.contains( "." ) ) - { - if ( !filters.containsKey( path ) ) - { - filters.put( path, new FilterOps() ); - } - - return (FilterOps) filters.get( path ); - } - - String[] split = path.split( "\\." ); - - Map c = filters; - - for ( int i = 0; i < split.length; i++ ) - { - boolean last = (i == (split.length - 1)); - - if ( c.containsKey( split[i] ) ) - { - if ( FilterOps.class.isInstance( c.get( split[i] ) ) ) - { - if ( last ) - { - return (FilterOps) c.get( split[i] ); - } - else - { - FilterOps self = (FilterOps) c.get( split[i] ); - Map map = Maps.newHashMap(); - map.put( "__self__", self ); - - c.put( split[i], map ); - c = map; - } - } - else - { - c = (Map) c.get( split[i] ); - } - } - else - { - if ( last ) - { - FilterOps filterOps = new FilterOps(); - c.put( split[i], filterOps ); - return filterOps; - } - else - { - Map map = Maps.newHashMap(); - c.put( split[i], map ); - c = map; - } - } - } - - return null; - } - - public Map getFilters() - { - return filters; - } - - public void setFilters( Map filters ) - { - this.filters = filters; - } - - @Override - public String toString() - { - return "Filters{" + - "filters=" + filters + - '}'; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java 2014-03-12 08:32:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java 1970-01-01 00:00:00 +0000 @@ -1,85 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -public class GtOp extends Op -{ - @Override - public OpStatus evaluate( Object object ) - { - if ( getValue() == null || object == null ) - { - return OpStatus.IGNORE; - } - - if ( Integer.class.isInstance( object ) ) - { - Integer s1 = getValue( Integer.class ); - Integer s2 = (Integer) object; - - return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Float.class.isInstance( object ) ) - { - Float s1 = getValue( Float.class ); - Float s2 = (Float) object; - - return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Collection.class.isInstance( object ) ) - { - Collection collection = (Collection) object; - Integer size = getValue( Integer.class ); - - if ( size != null && collection.size() > size ) - { - return OpStatus.INCLUDE; - } - else - { - return OpStatus.EXCLUDE; - } - } - else if ( Date.class.isInstance( object ) ) - { - Date s1 = getValue( Date.class ); - Date s2 = (Date) object; - - return (s1 != null && s2.after( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java 2014-03-12 08:32:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java 1970-01-01 00:00:00 +0000 @@ -1,85 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -public class GteOp extends Op -{ - @Override - public OpStatus evaluate( Object object ) - { - if ( getValue() == null || object == null ) - { - return OpStatus.IGNORE; - } - - if ( Integer.class.isInstance( object ) ) - { - Integer s1 = getValue( Integer.class ); - Integer s2 = (Integer) object; - - return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Float.class.isInstance( object ) ) - { - Float s1 = getValue( Float.class ); - Float s2 = (Float) object; - - return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Collection.class.isInstance( object ) ) - { - Collection collection = (Collection) object; - Integer size = getValue( Integer.class ); - - if ( size != null && collection.size() >= size ) - { - return OpStatus.INCLUDE; - } - else - { - return OpStatus.EXCLUDE; - } - } - else if ( Date.class.isInstance( object ) ) - { - Date s1 = getValue( Date.class ); - Date s2 = (Date) object; - - return (s1 != null && (s2.after( s1 ) || s2.equals( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java 2014-03-12 08:16:09 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java 1970-01-01 00:00:00 +0000 @@ -1,54 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** -* @author Morten Olav Hansen -*/ -public class LikeOp extends Op -{ - @Override - public OpStatus evaluate( Object object ) - { - if ( getValue() == null || object == null ) - { - return OpStatus.IGNORE; - } - - if ( String.class.isInstance( object ) ) - { - String s1 = getValue( String.class ); - String s2 = (String) object; - - return (s1 != null && s2.toLowerCase().contains( s1.toLowerCase() )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java 2014-03-12 08:32:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java 1970-01-01 00:00:00 +0000 @@ -1,85 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -public class LtOp extends Op -{ - @Override - public OpStatus evaluate( Object object ) - { - if ( getValue() == null || object == null ) - { - return OpStatus.IGNORE; - } - - if ( Integer.class.isInstance( object ) ) - { - Integer s1 = getValue( Integer.class ); - Integer s2 = (Integer) object; - - return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Float.class.isInstance( object ) ) - { - Float s1 = getValue( Float.class ); - Float s2 = (Float) object; - - return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Collection.class.isInstance( object ) ) - { - Collection collection = (Collection) object; - Integer size = getValue( Integer.class ); - - if ( size != null && collection.size() < size ) - { - return OpStatus.INCLUDE; - } - else - { - return OpStatus.EXCLUDE; - } - } - else if ( Date.class.isInstance( object ) ) - { - Date s1 = getValue( Date.class ); - Date s2 = (Date) object; - - return (s1 != null && (s2.before( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java 2014-03-12 08:32:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java 1970-01-01 00:00:00 +0000 @@ -1,85 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -public class LteOp extends Op -{ - @Override - public OpStatus evaluate( Object object ) - { - if ( getValue() == null || object == null ) - { - return OpStatus.IGNORE; - } - - if ( Integer.class.isInstance( object ) ) - { - Integer s1 = getValue( Integer.class ); - Integer s2 = (Integer) object; - - return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Float.class.isInstance( object ) ) - { - Float s1 = getValue( Float.class ); - Float s2 = (Float) object; - - return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - else if ( Collection.class.isInstance( object ) ) - { - Collection collection = (Collection) object; - Integer size = getValue( Integer.class ); - - if ( size != null && collection.size() <= size ) - { - return OpStatus.INCLUDE; - } - else - { - return OpStatus.EXCLUDE; - } - } - else if ( Date.class.isInstance( object ) ) - { - Date s1 = getValue( Date.class ); - Date s2 = (Date) object; - - return (s1 != null && (s2.before( s1 ) || s2.equals( s1 ))) ? OpStatus.INCLUDE : OpStatus.EXCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java 2014-03-12 08:16:09 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java 1970-01-01 00:00:00 +0000 @@ -1,55 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** -* @author Morten Olav Hansen -*/ -public class NeqOp extends Op -{ - private Op op = OpFactory.create( "eq" ); - - @Override - public OpStatus evaluate( Object object ) - { - op.setValue( getValue() ); - OpStatus status = op.evaluate( object ); - - // switch status from EqOp - switch ( status ) - { - case INCLUDE: - return OpStatus.EXCLUDE; - case EXCLUDE: - return OpStatus.INCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java 2014-03-12 08:16:09 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java 1970-01-01 00:00:00 +0000 @@ -1,52 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** -* @author Morten Olav Hansen -*/ -public class NullOp extends Op -{ - @Override - public boolean wantValue() - { - return false; - } - - @Override - public OpStatus evaluate( Object object ) - { - if ( object == null ) - { - return OpStatus.INCLUDE; - } - - return OpStatus.IGNORE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.java 2014-03-12 08:32:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.java 1970-01-01 00:00:00 +0000 @@ -1,123 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -public abstract class Op -{ - private String value; - - private static SimpleDateFormat[] simpleDateFormats = new SimpleDateFormat[]{ - new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ" ), - new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" ), - new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm" ), - new SimpleDateFormat( "yyyy-MM-dd'T'HH" ), - new SimpleDateFormat( "yyyyMMdd" ), - new SimpleDateFormat( "yyyyMM" ), - new SimpleDateFormat( "yyyy" ) - }; - - public boolean wantValue() - { - return true; - } - - public void setValue( String value ) - { - this.value = value; - } - - public String getValue() - { - return value; - } - - @SuppressWarnings( "unchecked" ) - public T getValue( Class klass ) - { - if ( klass.isInstance( value ) ) - { - return (T) value; - } - - if ( Boolean.class.isAssignableFrom( klass ) ) - { - try - { - return (T) Boolean.valueOf( value ); - } - catch ( Exception ignored ) - { - } - } - else if ( Integer.class.isAssignableFrom( klass ) ) - { - try - { - return (T) Integer.valueOf( value ); - } - catch ( Exception ignored ) - { - } - } - else if ( Float.class.isAssignableFrom( klass ) ) - { - try - { - return (T) Float.valueOf( value ); - } - catch ( Exception ignored ) - { - } - } - else if ( Date.class.isAssignableFrom( klass ) ) - { - for ( SimpleDateFormat simpleDateFormat : simpleDateFormats ) - { - try - { - return (T) simpleDateFormat.parse( value ); - } - catch ( ParseException ignored ) - { - } - } - } - - return null; - } - - public abstract OpStatus evaluate( Object object ); -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/OpFactory.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/OpFactory.java 2014-03-10 04:51:30 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/OpFactory.java 1970-01-01 00:00:00 +0000 @@ -1,82 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.google.common.collect.Maps; - -import java.util.Map; - -/** - * @author Morten Olav Hansen - */ -public class OpFactory -{ - protected static Map> register = Maps.newHashMap(); - - static - { - register( "eq", EqOp.class ); - register( "neq", NeqOp.class ); - register( "like", LikeOp.class ); - register( "gt", GtOp.class ); - register( "gte", GteOp.class ); - register( "lt", LtOp.class ); - register( "lte", LteOp.class ); - register( "null", NullOp.class ); - register( "empty", EmptyCollectionOp.class ); - } - - public static void register( String type, Class opClass ) - { - register.put( type.toLowerCase(), opClass ); - } - - public static boolean canCreate( String type ) - { - return register.containsKey( type.toLowerCase() ); - } - - public static Op create( String type ) - { - Class opClass = register.get( type.toLowerCase() ); - - try - { - return opClass.newInstance(); - } - catch ( InstantiationException ignored ) - { - } - catch ( IllegalAccessException ignored ) - { - } - - return null; - } -} === removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/OpStatus.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/OpStatus.java 2014-03-10 04:51:30 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/OpStatus.java 1970-01-01 00:00:00 +0000 @@ -1,37 +0,0 @@ -package org.hisp.dhis.api.utils.ops; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** -* @author Morten Olav Hansen -*/ -public enum OpStatus -{ - INCLUDE, EXCLUDE, IGNORE -}