Created
November 21, 2014 20:52
-
-
Save dardison/27fdd556ef9886f80154 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.asbitec.vbi.framework.shared.model; | |
| import java.io.Serializable; | |
| /** | |
| * Interface markup modelos de Datos | |
| * | |
| * @author daniel | |
| * | |
| */ | |
| public interface Model extends Serializable { | |
| } | |
| package com.asbitec.vbi.framework.shared.model; | |
| @SuppressWarnings("serial") | |
| public class ModelDTO implements Model { | |
| } | |
| package com.asbitec.vbi.framework.shared.model.category; | |
| import com.asbitec.vbi.framework.shared.model.ModelDTO; | |
| import com.asbitec.vbi.framework.shared.model.filters.Filter; | |
| @SuppressWarnings("serial") | |
| public abstract class Category extends ModelDTO { | |
| /** | |
| * ID Propiedad | |
| */ | |
| private String property; | |
| /** | |
| * Etiqueta localizada en el cliente | |
| */ | |
| private String label; | |
| /** | |
| * Valor provisto por el {@link PropertyEditor} | |
| */ | |
| private String textValue; | |
| public Category() { | |
| super(); | |
| } | |
| public Category(String property) { | |
| super(); | |
| this.property = property; | |
| } | |
| public String getProperty() { | |
| return property; | |
| } | |
| public void setProperty(String property) { | |
| this.property = property; | |
| } | |
| public String getLabel() { | |
| return label; | |
| } | |
| public void setLabel(String label) { | |
| this.label = label; | |
| } | |
| @Override | |
| public int hashCode() { | |
| final int prime = 31; | |
| int result = 1; | |
| result = prime * result | |
| + ((property == null) ? 0 : property.hashCode()); | |
| return result; | |
| } | |
| @Override | |
| public boolean equals(Object obj) { | |
| if (this == obj) | |
| return true; | |
| if (obj == null) | |
| return false; | |
| if (getClass() != obj.getClass()) | |
| return false; | |
| Category other = (Category) obj; | |
| if (property == null) { | |
| if (other.property != null) | |
| return false; | |
| } else if (!property.equals(other.property)) | |
| return false; | |
| return true; | |
| } | |
| @Override | |
| public String toString() { | |
| if(this.label!=null){ | |
| return label; | |
| }else{ | |
| return property; | |
| } | |
| } | |
| /** | |
| * Devuelve el Filtro por igual que corresponde al Valor de la Categoria | |
| * @return | |
| */ | |
| public abstract Filter getFilter(); | |
| public String getTextValue() { | |
| return textValue; | |
| } | |
| public void setTextValue(String textValue) { | |
| this.textValue = textValue; | |
| } | |
| } | |
| package com.asbitec.vbi.framework.shared.model.category; | |
| @SuppressWarnings("serial") | |
| public abstract class CategoryValue<V> extends Category { | |
| private V value; | |
| public CategoryValue() { | |
| super(); | |
| } | |
| public CategoryValue(String property) { | |
| super(property); | |
| } | |
| public CategoryValue(Category category){ | |
| super(category.getProperty()); | |
| this.setLabel(category.getLabel()); | |
| } | |
| public V getValue() { | |
| return value; | |
| } | |
| public void setValue(V value) { | |
| this.value = value; | |
| } | |
| @Override | |
| public int hashCode() { | |
| int result = super.hashCode(); | |
| result = result | |
| + ((getValue() == null) ? 0 : getValue().hashCode()); | |
| return result; | |
| } | |
| } | |
| package com.asbitec.vbi.framework.shared.model.category.calendar; | |
| import java.util.Date; | |
| import com.asbitec.vbi.framework.shared.model.calendar.DateInterval; | |
| import com.asbitec.vbi.framework.shared.model.calendar.DatePeriod; | |
| import com.asbitec.vbi.framework.shared.model.category.Category; | |
| import com.asbitec.vbi.framework.shared.model.category.CategoryValue; | |
| import com.asbitec.vbi.framework.shared.model.filters.DateFilterPeriod; | |
| import com.asbitec.vbi.framework.shared.model.filters.Filter; | |
| import com.asbitec.vbi.framework.shared.model.filters.interval.DateIntervalFilter; | |
| @SuppressWarnings("serial") | |
| public class DateIntervalCategoryValue extends CategoryValue<DatePeriod> { | |
| public DateIntervalCategoryValue() { | |
| super(); | |
| } | |
| public DateIntervalCategoryValue(Category category) { | |
| super(category); | |
| } | |
| public DateIntervalCategoryValue(String property) { | |
| super(property); | |
| } | |
| @Override | |
| public Filter getFilter() { | |
| DateInterval interval=this.getInterval(); | |
| if(interval!=null){ | |
| DateIntervalFilter result=new DateIntervalFilter(getProperty(), | |
| interval.getFrom(), | |
| interval.getTo()); | |
| return result; | |
| }else{ | |
| return null; | |
| } | |
| } | |
| protected void setPeriodType(DateFilterPeriod period){ | |
| DatePeriod dp=new DatePeriod(period); | |
| this.setValue(dp); | |
| } | |
| public void setNumber(Integer number){ | |
| DatePeriod period=this.getValue(); | |
| if(period!=null) | |
| period.setNumber(number); | |
| } | |
| public Integer getNumber(){ | |
| if(this.getValue()!=null){ | |
| return this.getValue().getNumber(); | |
| }else{ | |
| return null; | |
| } | |
| } | |
| public void setInterval(Date from, Date to){ | |
| DateInterval interval=new DateInterval(from, to); | |
| if(this.getValue()!=null) | |
| this.getValue().setInterval(interval); | |
| } | |
| public void setInterval(DateInterval interval){ | |
| DatePeriod period=this.getValue(); | |
| if(period!=null){ | |
| period.setInterval(interval); | |
| } | |
| } | |
| public DateInterval getInterval(){ | |
| if(this.getValue()==null){ | |
| return null; | |
| }else{ | |
| return this.getValue().getInterval(); | |
| } | |
| } | |
| } | |
| package com.asbitec.vbi.framework.shared.model.category.calendar; | |
| import com.asbitec.vbi.framework.shared.model.calendar.DatePeriod; | |
| import com.asbitec.vbi.framework.shared.model.category.Category; | |
| import com.asbitec.vbi.framework.shared.model.filters.DateFilterPeriod; | |
| @SuppressWarnings("serial") | |
| public class MonthPeriodCategory extends DateIntervalCategoryValue { | |
| public MonthPeriodCategory() { | |
| super(); | |
| } | |
| public MonthPeriodCategory(String property) { | |
| super(property); | |
| DatePeriod period=new DatePeriod(DateFilterPeriod.MONTH); | |
| this.setValue(period); | |
| } | |
| public MonthPeriodCategory(Category category) { | |
| super(category); | |
| DatePeriod period=new DatePeriod(DateFilterPeriod.MONTH); | |
| this.setValue(period); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment