public code v1
This commit is contained in:
@@ -0,0 +1,220 @@
|
||||
package flintstones.entity.valuation;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.entity.domain.Domain;
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
import flintstones.entity.valuation.exception.InvalidValueException;
|
||||
import flintstones.entity.valuation.messages.Messages;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
|
||||
/**
|
||||
* The Class Valuation.
|
||||
*/
|
||||
public abstract class Valuation implements Cloneable, Comparable<Valuation> {
|
||||
|
||||
/** The messages. */
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
/** The domain. */
|
||||
protected Domain domain;
|
||||
|
||||
/** The id. */
|
||||
private String id;
|
||||
|
||||
/** The name. */
|
||||
private String name;
|
||||
|
||||
/** The evaluated. */
|
||||
private boolean evaluated = false;
|
||||
|
||||
/** The Constant EXTENSION_POINT. */
|
||||
public static String EXTENSION_POINT = "flintstones.valuation"; //$NON-NLS-1$
|
||||
|
||||
/** The image. */
|
||||
public static String IMAGE = "valuation.png";; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public enum Fields implements ExtensionEnum {
|
||||
|
||||
/** The Valuation. */
|
||||
Valuation,
|
||||
/** The id. */
|
||||
uid,
|
||||
/** The name. */
|
||||
name,
|
||||
/** The implementation. */
|
||||
implementation,
|
||||
/** The domain. */
|
||||
domain,
|
||||
/** The type. */
|
||||
type,
|
||||
/** The is intermediate. */
|
||||
is_intermediate,
|
||||
/** The Valuations. */
|
||||
Valuations,
|
||||
/** The alternative. */
|
||||
alternative,
|
||||
/** The criterion. */
|
||||
criterion,
|
||||
/** The expert. */
|
||||
expert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new valuation.
|
||||
*/
|
||||
public Valuation() {
|
||||
this.domain = null;
|
||||
this.id = null;
|
||||
this.name = null;
|
||||
}
|
||||
|
||||
public void setValueFromString(String value) {
|
||||
|
||||
if(value == null)
|
||||
throw new InvalidValueException("Debes rellenar el valor. ");
|
||||
|
||||
if(domain == null)
|
||||
throw new InvalidValueException("Debes asignar un dominio antes de evaluar. ");
|
||||
|
||||
initFromString(value);
|
||||
}
|
||||
|
||||
protected abstract void initFromString(String value);
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the domain.
|
||||
*
|
||||
* @param domain the new domain
|
||||
*/
|
||||
public void setDomain(Domain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the domain.
|
||||
*
|
||||
* @return the domain
|
||||
*/
|
||||
public Domain getDomain() {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#clone() */
|
||||
@Override
|
||||
public Object clone() {
|
||||
// throw new RuntimeException("No se puede clonar así");
|
||||
|
||||
Valuation result = null;
|
||||
|
||||
try {
|
||||
result = (Valuation) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
if(domain != null) {
|
||||
result.domain = (Domain) domain.clone();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Negate valuation.
|
||||
*
|
||||
* @return the valuation
|
||||
*/
|
||||
public abstract Valuation negateValuation();
|
||||
|
||||
/**
|
||||
* Change format valuation to string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public abstract String changeFormatValuationToString();
|
||||
|
||||
/**
|
||||
* Checks if is evaluated.
|
||||
*
|
||||
* @return true, if is evaluated
|
||||
*/
|
||||
public boolean isEvaluated() {
|
||||
return this.evaluated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the evaluated.
|
||||
*
|
||||
* @param status the new evaluated
|
||||
*/
|
||||
public void setEvaluated(boolean status) {
|
||||
this.evaluated = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write.
|
||||
*
|
||||
* @param writer the writer
|
||||
* @throws XMLStreamException the XML stream exception
|
||||
*/
|
||||
public abstract void write(XMLStreamWriter writer) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Read.
|
||||
*
|
||||
* @param node the node
|
||||
*/
|
||||
public abstract void read(WNode node);
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package flintstones.entity.valuation.exception;
|
||||
|
||||
public class InvalidValueException extends RuntimeException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2367035980186200517L;
|
||||
|
||||
public InvalidValueException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.entity.valuation.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings({ "javadoc", "nls" })
|
||||
public class Messages {
|
||||
|
||||
public String Valuation_entity = "Valuation";
|
||||
public String Valuation_image = "valuation.png";
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Valuation_entity=valuation
|
||||
Valuation_extension=flintstones.valuation
|
||||
Valuation_image=valuation.png
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Valuation_entity=Evaluación
|
||||
Valuation_extension=flintstones.valuation
|
||||
Valuation_image=valuation.png
|
||||
Reference in New Issue
Block a user