r1192 - in trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities: . attachment data metadata
Author: glandais Date: 2008-02-22 16:46:35 +0000 (Fri, 22 Feb 2008) New Revision: 1192 Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Descriptor.java Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityHelper.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleEntityVisitor.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/attachment/Attachment.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Code.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Constant.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ConstantValue.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/DataEntity.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Repository.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Result.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Structure.java trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaData.java Log: Entities are independant of MetaData Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityHelper.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/EntityHelper.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.StringTokenizer; import javax.swing.tree.DefaultMutableTreeNode; @@ -70,20 +71,9 @@ if (entity == null) { return ""; } - if (entity instanceof LoggableElement) { - return getLibelle((LoggableElement) entity); - } return getLibelle(entity.getClass().getSimpleName()); } - public static String getLibelle(LoggableElement element) { - return element == null ? "" : getLibelle(element.getMetaData()); - } - - public static String getLibelle(MetaData data) { - return data == null ? "" : getLibelle(data.getType()); - } - public String getLibelle() { return _(i18nKey); } @@ -108,6 +98,10 @@ } return ""; } + + public static Type getType(Class<?> klass) { + return Type.valueOf(klass.getSimpleName()); + } private Type(boolean isLE,String i18nKey, String i18nKeys) { this.le = isLE; @@ -142,9 +136,9 @@ } public boolean accept(MetaData metaData) { - return metaData != null && accept(metaData.getType()); + return metaData != null && accept(metaData.getElementClass()); } - + private Action(Class<?>... classes) { this.classes = Arrays.asList(classes); this.types = new ArrayList<String>(classes.length); Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleEntityVisitor.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleEntityVisitor.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/SimpleEntityVisitor.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -88,7 +88,8 @@ public void visitMetaData(MetaData v) { if (v != null) { - visitAttachments(v.getAttachments()); + // FIXME !!! + //visitAttachments(v.getAttachments()); } } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/attachment/Attachment.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/attachment/Attachment.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/attachment/Attachment.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -18,6 +18,7 @@ package fr.cemagref.simexplorer.is.entities.attachment; import org.apache.commons.lang.StringUtils; + import fr.cemagref.simexplorer.is.entities.BaseEntity; import fr.cemagref.simexplorer.is.entities.EntityVisitor; @@ -52,8 +53,7 @@ /** * Sets the file name. * - * @param fileName - * the new file name + * @param fileName the new file name */ public void setFileName(String fileName) { this.fileName = fileName; @@ -71,8 +71,7 @@ /** * Sets the content type. * - * @param contentType - * the new content type + * @param contentType the new content type */ public void setContentType(ContentType contentType) { this.contentType = contentType; @@ -90,8 +89,7 @@ /** * Sets the data hash. * - * @param dataHash - * the new data hash + * @param dataHash the new data hash */ public void setDataHash(String dataHash) { this.dataHash = StringUtils.leftPad(dataHash, 32, '0'); @@ -110,8 +108,7 @@ /** * Gets the hash from unique id. * - * @param uniqueId - * the unique id + * @param uniqueId the unique id * * @return the hash from unique id */ @@ -122,8 +119,7 @@ /** * Gets the file name from unique id. * - * @param uniqueId - * the unique id + * @param uniqueId the unique id * * @return the file name from unique id */ @@ -138,10 +134,8 @@ public int hashCode() { final int prime = 31; int result = 1; - result = prime * result - + ((dataHash == null) ? 0 : dataHash.hashCode()); - result = prime * result - + ((fileName == null) ? 0 : fileName.hashCode()); + result = prime * result + ((dataHash == null) ? 0 : dataHash.hashCode()); + result = prime * result + ((fileName == null) ? 0 : fileName.hashCode()); return result; } @@ -176,7 +170,7 @@ @Override public String toString() { StringBuffer sb = new StringBuffer(); - sb.append(getFileName()); + sb.append(getFileName()); if (getContentType() != null) { sb.append(" - ").append(getContentType().getDescription()); } @@ -186,4 +180,5 @@ public void accept(EntityVisitor visitor) { visitor.visitAttachment(this); } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Code.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Code.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Code.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,10 +17,10 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; +import java.io.Serializable; + import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.io.Serializable; - /** * The Class Code. */ @@ -47,8 +47,7 @@ /** * Sets the language. * - * @param language - * the new language + * @param language the new language */ public void setLanguage(String language) { this.language = language; @@ -66,8 +65,7 @@ /** * Sets the code. * - * @param code - * the new code + * @param code the new code */ public void setCode(String code) { this.code = code; @@ -84,4 +82,36 @@ public void accept(EntityVisitor visitor) { visitor.visitCode(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((code == null) ? 0 : code.hashCode()); + result = prime * result + ((language == null) ? 0 : language.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Code other = (Code) obj; + if (code == null) { + if (other.code != null) + return false; + } else if (!code.equals(other.code)) + return false; + if (language == null) { + if (other.language != null) + return false; + } else if (!language.equals(other.language)) + return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Component.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,13 +17,12 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; -import fr.cemagref.simexplorer.is.entities.EntityVisitor; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import java.util.Set; +import fr.cemagref.simexplorer.is.entities.EntityVisitor; + /** * The Class Component. */ @@ -56,8 +55,7 @@ /** * Sets the constants. * - * @param constants - * the new constants + * @param constants the new constants */ public void setConstants(List<Constant> constants) { this.constants = constants; @@ -75,8 +73,7 @@ /** * Sets the structures. * - * @param structures - * the new structures + * @param structures the new structures */ public void setStructures(List<Structure> structures) { this.structures = structures; @@ -94,8 +91,7 @@ /** * Sets the codes. * - * @param codes - * the new codes + * @param codes the new codes */ public void setCodes(List<Code> codes) { this.codes = codes; @@ -113,8 +109,7 @@ /** * Sets the libraries. * - * @param libraries - * the new libraries + * @param libraries the new libraries */ public void setLibraries(List<Library> libraries) { this.libraries = libraries; @@ -133,4 +128,48 @@ public void accept(EntityVisitor visitor) { visitor.visitComponent(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((codes == null) ? 0 : codes.hashCode()); + result = prime * result + ((constants == null) ? 0 : constants.hashCode()); + result = prime * result + ((libraries == null) ? 0 : libraries.hashCode()); + result = prime * result + ((structures == null) ? 0 : structures.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Component other = (Component) obj; + if (codes == null) { + if (other.codes != null) + return false; + } else if (!codes.equals(other.codes)) + return false; + if (constants == null) { + if (other.constants != null) + return false; + } else if (!constants.equals(other.constants)) + return false; + if (libraries == null) { + if (other.libraries != null) + return false; + } else if (!libraries.equals(other.libraries)) + return false; + if (structures == null) { + if (other.structures != null) + return false; + } else if (!structures.equals(other.structures)) + return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Constant.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Constant.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Constant.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,10 +17,10 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; +import java.io.Serializable; + import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.io.Serializable; - /** The Class Constant. */ public class Constant extends DataEntity implements Serializable { @@ -80,4 +80,38 @@ public void accept(EntityVisitor visitor) { visitor.visitConstant(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.getCanonicalName().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Constant other = (Constant) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.getCanonicalName().equals(other.type.getCanonicalName())) + return false; + return true; + } + + + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ConstantValue.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ConstantValue.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ConstantValue.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,10 +17,10 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; +import java.io.Serializable; + import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.io.Serializable; - /** * The Class ConstantValue. */ @@ -47,8 +47,7 @@ /** * Sets the value. * - * @param value - * the new value + * @param value the new value */ public void setValue(String value) { this.value = value; @@ -66,8 +65,7 @@ /** * Sets the constant. * - * @param constant - * the new constant + * @param constant the new constant */ public void setConstant(Constant constant) { this.constant = constant; @@ -77,4 +75,35 @@ visitor.visitConstantValue(this); } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((constant == null) ? 0 : constant.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final ConstantValue other = (ConstantValue) obj; + if (constant == null) { + if (other.constant != null) + return false; + } else if (!constant.equals(other.constant)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/DataEntity.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/DataEntity.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/DataEntity.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -24,47 +24,25 @@ */ public abstract class DataEntity implements BaseEntity { - /** The parent data. */ - private DataEntity parentData; - /** The Constant serialVersionUID. */ private static final long serialVersionUID = -2570073990226703994L; - /** - * Gets the parent loggable element. - * - * @return the parent loggable element - */ - public LoggableElement getParentLoggableElement() { - LoggableElement parentLoggableElement = null; - if (getParentData() instanceof LoggableElement) { - parentLoggableElement = (LoggableElement) getParentData(); - } else { - if (getParentData() != null) { - parentLoggableElement = getParentData() - .getParentLoggableElement(); - } - } - return parentLoggableElement; + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + return result; } - /** - * Gets the parent data. - * - * @return the parentData - */ - public DataEntity getParentData() { - return parentData; + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + return true; } - /** - * Sets the parent data. - * - * @param parentData - * the parentData to set - */ - public void setParentData(DataEntity parentData) { - this.parentData = parentData; - } - } Added: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Descriptor.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Descriptor.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Descriptor.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -0,0 +1,132 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.entities.data; + +import fr.cemagref.simexplorer.is.entities.BaseEntity; +import fr.cemagref.simexplorer.is.entities.EntityVisitor; + +/** + * The Class Descriptor. + */ +public class Descriptor implements BaseEntity, Comparable<Descriptor> { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = -7429465085491453048L; + + /** The name. */ + private String name; + + /** The value. */ + private String value; + + /** + * Instantiates a new descriptor. + * + * @param name the name + * @param value the value + */ + public Descriptor(String name, String value) { + super(); + this.name = name; + this.value = value; + } + + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.entities.EntityVisitable#accept(fr.cemagref.simexplorer.is.entities.EntityVisitor) + */ + @Override + public void accept(EntityVisitor visitor) { + // nothing... yet! + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the value. + * + * @return the value + */ + public String getValue() { + return value; + } + + /** + * Sets the value. + * + * @param value the new value + */ + public void setValue(String value) { + this.value = value; + } + + @Override + public int compareTo(Descriptor o) { + if (this.getName() == null || o == null || o.getName() == null) { + return 0; + } + return this.getName().compareTo(o.getName()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((value == null) ? 0 : value.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; + final Descriptor other = (Descriptor) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } + +} Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationApplication.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,18 +17,16 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; -import fr.cemagref.simexplorer.is.entities.EntityVisitor; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import java.util.Set; +import fr.cemagref.simexplorer.is.entities.EntityVisitor; + /** * The Class ExplorationApplication. */ -public class ExplorationApplication extends LoggableElement implements - Serializable { +public class ExplorationApplication extends LoggableElement implements Serializable { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 122049347724394193L; @@ -51,8 +49,7 @@ /** * Sets the explorations. * - * @param explorations - * the new explorations + * @param explorations the new explorations */ public void setExplorations(List<ExplorationData> explorations) { this.explorations = explorations; @@ -70,8 +67,7 @@ /** * Sets the components. * - * @param components - * the new components + * @param components the new components */ public void setComponents(List<Component> components) { this.components = components; @@ -91,4 +87,36 @@ public void accept(EntityVisitor visitor) { visitor.visitExplorationApplication(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((components == null) ? 0 : components.hashCode()); + result = prime * result + ((explorations == null) ? 0 : explorations.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final ExplorationApplication other = (ExplorationApplication) obj; + if (components == null) { + if (other.components != null) + return false; + } else if (!components.equals(other.components)) + return false; + if (explorations == null) { + if (other.explorations != null) + return false; + } else if (!explorations.equals(other.explorations)) + return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/ExplorationData.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,12 +17,11 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; -import fr.cemagref.simexplorer.is.entities.EntityVisitor; - import java.io.Serializable; import java.util.List; -import java.util.Set; +import fr.cemagref.simexplorer.is.entities.EntityVisitor; + /** * The Class ExplorationData. */ @@ -40,8 +39,7 @@ /** * Find constant value. * - * @param c - * the constant to find + * @param c the constant to find * * @return the constant value */ @@ -57,10 +55,8 @@ /** * Sets the constant value. * - * @param c - * the constant to set - * @param value - * the value + * @param c the constant to set + * @param value the value */ public void setConstantValue(Constant c, String value) { ConstantValue constantValue = findConstantValue(c); @@ -75,8 +71,7 @@ /** * Gets the constant value. * - * @param c - * the c + * @param c the c * * @return the constant value */ @@ -100,8 +95,7 @@ /** * Sets the result. * - * @param result - * the new result + * @param result the new result */ public void setResult(Result result) { this.result = result; @@ -119,8 +113,7 @@ /** * Sets the values map. * - * @param constantValues - * the new values map + * @param constantValues the new values map */ public void setConstantValues(List<ConstantValue> constantValues) { this.constantValues = constantValues; @@ -137,4 +130,36 @@ public void accept(EntityVisitor visitor) { visitor.visitExplorationData(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((constantValues == null) ? 0 : constantValues.hashCode()); + result = prime * result + ((this.result == null) ? 0 : this.result.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final ExplorationData other = (ExplorationData) obj; + if (constantValues == null) { + if (other.constantValues != null) + return false; + } else if (!constantValues.equals(other.constantValues)) + return false; + if (result == null) { + if (other.result != null) + return false; + } else if (!result.equals(other.result)) + return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Library.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,10 +17,10 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.data; +import java.util.List; + import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.util.List; - /** The Class Library. */ public class Library extends LoggableElement { @@ -38,4 +38,33 @@ public void accept(EntityVisitor visitor) { visitor.visitLibrary(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + // add properties hashes + // result = prime * result + property.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Library other = (Library) obj; + // add properties tests + // if (property == null) { + // if (other.property != null) + // return false; + // } else if (!property.equals(other.property)) + // return false; + return true; + } + + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/LoggableElement.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; +import fr.cemagref.simexplorer.is.entities.attachment.Attachment; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; /** @@ -27,39 +28,30 @@ */ public abstract class LoggableElement extends DataEntity { - /** The meta data. */ - private MetaData metaData; - + /** The name. */ + private String name; + + /** The description. */ + private String description; + + /** The descriptors. */ + private List<Descriptor> descriptors; + + /** The attachments. */ + private List<Attachment> attachments; + + /** The metadata IS, managed only by SimExplorer-IS. */ + private MetaData metadataIS; + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 2000267650904269217L; - /** - * Gets the meta data. - * - * @return the metaData - */ - public MetaData getMetaData() { - return metaData; - } - - /** - * Sets the meta data. - * - * @param metaData the metaData to set - */ - public void setMetaData(MetaData metaData) { - this.metaData = metaData; - } - /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { - if (metaData == null) { - return super.toString(); - } - return metaData.getName() + " [" + metaData.getVersion() + ']'; + return getName(); } /** @@ -88,4 +80,177 @@ return children; } + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets the name. + * + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the description. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Sets the description. + * + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the descriptors. + * + * @return the descriptors + */ + public List<Descriptor> getDescriptors() { + return descriptors; + } + + /** + * Sets the descriptors. + * + * @param descriptors the descriptors to set + */ + public void setDescriptors(List<Descriptor> descriptors) { + this.descriptors = descriptors; + } + + /** + * Gets the attachments. + * + * @return the attachments + */ + public List<Attachment> getAttachments() { + if (attachments == null) { + attachments = new ArrayList<Attachment>(); + } + return attachments; + } + + /** + * Get attachment by his index. + * + * @param attachmentIndex index of attachment to find + * + * @return the correct attachment + */ + public Attachment getAttachment(Integer attachmentIndex) { + if (attachmentIndex != null && attachmentIndex > -1 && attachments != null && !attachments.isEmpty() + && attachments.size() > attachmentIndex) { + return attachments.get(attachmentIndex); + } + return null; + } + + /** + * Get attachment by his uniqueId. + * + * @param attachmentUniqueId unqiue id of attachment to find + * + * @return the correct attachment + */ + public Attachment getAttachment(String attachmentUniqueId) { + if (attachmentUniqueId != null && attachments != null && !attachments.isEmpty()) { + for (Attachment attachment : attachments) { + if (attachmentUniqueId.equals(attachment.getUniqueId())) { + return attachment; + } + } + } + return null; + } + + /** + * Sets the attachments. + * + * @param attachments the attachments to set + */ + public void setAttachments(List<Attachment> attachments) { + this.attachments = attachments; + } + + /** + * Gets the metadata is. If element is not retrieved through IS, this data is inconsistent + * + * @return the metadata is + */ + public MetaData getMetaData() { + return metadataIS; + } + + /** + * Sets the metadata is. Only the IS should set that value. + * + * @param metadataIS the new metadata is + */ + public void setMetaData(MetaData metadataIS) { + this.metadataIS = metadataIS; + } + + @Override + public int hashCode() { + // metadata is and should not included! + + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((attachments == null) ? 0 : attachments.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((descriptors == null) ? 0 : descriptors.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + // metadata is and should not included! + + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final LoggableElement other = (LoggableElement) obj; + if (attachments == null) { + if (other.attachments != null) + return false; + } else if (!attachments.equals(other.attachments)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (descriptors == null) { + if (other.descriptors != null) + return false; + } else if (!descriptors.equals(other.descriptors)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Repository.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Repository.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Repository.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -19,8 +19,6 @@ import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.io.Serializable; - /** * The Class Repository. */ @@ -32,4 +30,32 @@ public void accept(EntityVisitor visitor) { visitor.visitRepository(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + // add properties hashes + // result = prime * result + property.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Repository other = (Repository) obj; + // add properties tests + // if (property == null) { + // if (other.property != null) + // return false; + // } else if (!property.equals(other.property)) + // return false; + return true; + } + } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Result.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Result.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Result.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -19,8 +19,6 @@ import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.io.Serializable; - /** The Class Result. */ public class Result extends DataEntity { @@ -35,4 +33,31 @@ public void accept(EntityVisitor visitor) { visitor.visitResult(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + // add properties hashes + // result = prime * result + property.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Result other = (Result) obj; + // add properties tests + // if (property == null) { + // if (other.property != null) + // return false; + // } else if (!property.equals(other.property)) + // return false; + return true; + } } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Structure.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Structure.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/data/Structure.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -22,7 +22,7 @@ /** * The Class Structure. */ -public class Structure extends DataEntity { +public abstract class Structure extends DataEntity { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 2594331198459134006L; @@ -30,4 +30,31 @@ public void accept(EntityVisitor visitor) { visitor.visitStructure(this); } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + // add properties hashes + // result = prime * result + property.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + final Structure other = (Structure) obj; + // add properties tests + // if (property == null) { + // if (other.property != null) + // return false; + // } else if (!property.equals(other.property)) + // return false; + return true; + } } Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaData.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaData.java 2008-02-22 09:59:51 UTC (rev 1191) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/entities/metadata/MetaData.java 2008-02-22 16:46:35 UTC (rev 1192) @@ -17,16 +17,15 @@ * ##% */ package fr.cemagref.simexplorer.is.entities.metadata; -import fr.cemagref.simexplorer.is.entities.attachment.Attachment; +import java.util.Date; + import fr.cemagref.simexplorer.is.entities.BaseEntity; import fr.cemagref.simexplorer.is.entities.EntityVisitor; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** The Class MetaData. */ +/** + * The Class MetaData. Used by IS to store relative data of a LoggableElement. SimExplorer should not set properties of + * this class. + */ public class MetaData implements BaseEntity { /** The Constant serialVersionUID. */ @@ -35,42 +34,49 @@ /** The uuid. */ private String uuid; + /** The version. */ + private Version version; + /** The name. */ private String name; - /** The type. */ - private String type; - /** The description. */ private String description; - /** The version. */ - private Version version; - /** The creation date. */ private Date creationDate; /** The hash. */ private String hash; - /** The descriptors. */ - private Map<String, String> descriptors; - - /** The attachments. */ - private List<Attachment> attachments; - /** The parent version uuid. */ - private String parentVersionUuid; + private String parentUuid; /** The parent version version. */ - private String parentVersionVersion; + private Version parentVersion; /** The latest. */ private boolean latest; + /** The class name of the element. */ + private Class<?> elementClass; + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(getName()).append(" ").append(getUuid()); + if (version != null) { + sb.append(" [").append(getVersion()).append(']'); + } + return sb.toString(); + } + /** * Gets the uuid. - * + * * @return the uuid */ public String getUuid() { @@ -79,7 +85,7 @@ /** * Sets the uuid. - * + * * @param uuid the uuid to set */ public void setUuid(String uuid) { @@ -87,62 +93,8 @@ } /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets the name. - * - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets the type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Sets the type. - * - * @param type the type to set - */ - public void setType(String type) { - this.type = type; - } - - /** - * Gets the description. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Sets the description. - * - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** * Gets the version. - * + * * @return the version */ public Version getVersion() { @@ -151,7 +103,7 @@ /** * Sets the version. - * + * * @param version the version to set */ public void setVersion(String version) { @@ -159,8 +111,21 @@ } /** + * Sets the version. + * + * @param version the version to set + */ + public void setVersion(Version version) { + if (version == null) { + this.version = null; + } else { + this.version = version.safeClone(); + } + } + + /** * Gets the creation date. - * + * * @return the creationDate */ public Date getCreationDate() { @@ -169,7 +134,7 @@ /** * Sets the creation date. - * + * * @param creationDate the creationDate to set */ public void setCreationDate(Date creationDate) { @@ -178,7 +143,7 @@ /** * Gets the hash. - * + * * @return the hash */ public String getHash() { @@ -187,7 +152,7 @@ /** * Sets the hash. - * + * * @param hash the hash to set */ public void setHash(String hash) { @@ -195,129 +160,132 @@ } /** - * Gets the descriptors. - * - * @return the descriptors + * Gets the parent version uuid. + * + * @return the parentVersionUuid */ - public Map<String, String> getDescriptors() { - return descriptors; + public String getParentUuid() { + return parentUuid; } /** - * Sets the descriptors. - * - * @param descriptors the descriptors to set + * Sets the parent version uuid. + * + * @param parentUuid the parentUuid to set */ - public void setDescriptors(Map<String, String> descriptors) { - this.descriptors = descriptors; + public void setParentUuid(String parentUuid) { + this.parentUuid = parentUuid; } /** - * Gets the attachments. - * - * @return the attachments + * Gets the parent version version. + * + * @return the parentVersionVersion */ - public List<Attachment> getAttachments() { - if (attachments == null) { - attachments = new ArrayList<Attachment>(); - } - return attachments; + public Version getParentVersion() { + return parentVersion; } /** - * Get attachment by his index - * - * @param attachmentIndex index of attachment to find - * @return the correct attachment + * Sets the parent version version. + * + * @param parentVersion the parentVersionVersion to set */ - public Attachment getAttachment(Integer attachmentIndex) { - if (attachmentIndex != null && attachmentIndex > -1 && attachments != null && !attachments.isEmpty() && attachments.size() > attachmentIndex) { - return attachments.get(attachmentIndex); + public void setParentVersion(Version parentVersion) { + if (parentVersion == null) { + this.parentVersion = null; + } else { + this.parentVersion = parentVersion.safeClone(); } - return null; } /** - * Get attachment by his uniqueId - * - * @param attachmentUniqueId unqiue id of attachment to find - * @return the correct attachment + * Sets the parent version version. + * + * @param parentVersion the parentVersionVersion to set */ - public Attachment getAttachment(String attachmentUniqueId) { - if (attachmentUniqueId != null && attachments != null && !attachments.isEmpty()) { - for (Attachment attachment : attachments) { - if (attachmentUniqueId.equals(attachment.getUniqueId())) { - return attachment; - } - } - } - return null; + public void setParentVersion(String parentVersion) { + this.parentVersion = Version.valueOf(parentVersion); } /** - * Sets the attachments. - * - * @param attachments the attachments to set + * Checks if is latest. + * + * @return true, if is latest */ - public void setAttachments(List<Attachment> attachments) { - this.attachments = attachments; + public boolean isLatest() { + return latest; } /** - * Gets the parent version uuid. - * - * @return the parentVersionUuid + * Sets the latest. + * + * @param latest the new latest */ - public String getParentVersionUuid() { - return parentVersionUuid; + public void setLatest(boolean latest) { + this.latest = latest; } /** - * Sets the parent version uuid. - * - * @param parentVersionUuid the parentVersionUuid to set + * Gets the name. + * + * @return the name */ - public void setParentVersionUuid(String parentVersionUuid) { - this.parentVersionUuid = parentVersionUuid; + public String getName() { + return name; } /** - * Gets the parent version version. - * - * @return the parentVersionVersion + * Sets the name. + * + * @param name the new name */ - public String getParentVersionVersion() { - return parentVersionVersion; + public void setName(String name) { + this.name = name; } /** - * Sets the parent version version. - * - * @param parentVersionVersion the parentVersionVersion to set + * Gets the description. + * + * @return the description */ - public void setParentVersionVersion(String parentVersionVersion) { - this.parentVersionVersion = parentVersionVersion; + public String getDescription() { + return description; } /** - * Checks if is latest. - * - * @return true, if is latest + * Sets the description. + * + * @param description the new description */ - public boolean isLatest() { - return latest; + public void setDescription(String description) { + this.description = description; } + /* (non-Javadoc) + * @see fr.cemagref.simexplorer.is.entities.EntityVisitable#accept(fr.cemagref.simexplorer.is.entities.EntityVisitor) + */ + @Override + public void accept(EntityVisitor visitor) { + // nothing yet + } + /** - * Sets the latest. - * - * @param latest the new latest + * Gets the element class. + * + * @return the element class */ - public void setLatest(boolean latest) { - this.latest = latest; + public Class<?> getElementClass() { + return elementClass; } - public void accept(EntityVisitor visitor) { - visitor.visitMetaData(this); + /** + * Sets the element class. + * + * @param elementClass the new element class + */ + public void setElementClass(Class<?> elementClass) { + this.elementClass = elementClass; } + }
participants (1)
-
glandais@users.labs.libre-entreprise.org