public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>flintstones.group</groupId>
|
||||
<artifactId>flintstones.bundles</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>flintstones.entity.problemelement</artifactId>
|
||||
<version>1.0.0.qualfier</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Problemelements</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.entity.problemelement</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ds.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1779484362572</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,19 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Problemelements
|
||||
Bundle-SymbolicName: flintstones.entity.problemelement;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualfier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: flintstones.entity.problemelement;uses:="flintstones.entity.problemelement.entities",
|
||||
flintstones.entity.problemelement.entities;uses:="flintstones.helper.extensionpoint,flintstones.entity.problemelement.service",
|
||||
flintstones.entity.problemelement.messages,
|
||||
flintstones.entity.problemelement.provider;uses:="flintstones.entity.problemelement.entities"
|
||||
Automatic-Module-Name: flintstones.problemelements
|
||||
Require-Bundle: org.eclipse.e4.core.contexts,
|
||||
org.eclipse.e4.core.services,
|
||||
javax.inject,
|
||||
org.apache.commons.lang,
|
||||
flintstones.entity.extensionenum,
|
||||
flintstones.entity.common;visibility:=reexport
|
||||
@@ -0,0 +1,4 @@
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
source.. = src/
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
package flintstones.entity.problemelement;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The Class ProblemElementKey.
|
||||
*
|
||||
* @author Sinbad2
|
||||
* Unify expert, alternative and criterion into a class to be used in Maps.
|
||||
*/
|
||||
public class ProblemElementKey implements Cloneable, Comparable<ProblemElementKey> {
|
||||
|
||||
/** The expert. */
|
||||
private Expert expert;
|
||||
|
||||
/** The alternative. */
|
||||
private Alternative alternative;
|
||||
|
||||
/** The criterion. */
|
||||
private Criterion criterion;
|
||||
|
||||
/**
|
||||
* Instantiates a new problem element key.
|
||||
*
|
||||
* @param currentPE the current PE
|
||||
* @param pe1 the pe 1
|
||||
* @param pe2 the pe 2
|
||||
* @param b the b
|
||||
*/
|
||||
public ProblemElementKey(ProblemElement currentPE, ProblemElement pe1, ProblemElement pe2) {
|
||||
|
||||
if (currentPE instanceof Expert) {
|
||||
this.expert = (Expert) currentPE;
|
||||
this.criterion = (Criterion) pe1;
|
||||
this.alternative = (Alternative) pe2;
|
||||
} else if (currentPE instanceof Criterion) {
|
||||
this.criterion = (Criterion) currentPE;
|
||||
this.alternative = (Alternative) pe1;
|
||||
this.expert = (Expert) pe2;
|
||||
} else {
|
||||
this.alternative = (Alternative) currentPE;
|
||||
this.expert = (Expert) pe1;
|
||||
this.criterion = (Criterion) pe2;
|
||||
}
|
||||
}
|
||||
|
||||
public ProblemElementKey assign(ProblemElement pe) {
|
||||
if(pe.getType().equals(Expert.Type))
|
||||
expert = (Expert) pe;
|
||||
else if(pe.getType().equals(Criterion.Type))
|
||||
criterion = (Criterion) pe;
|
||||
else
|
||||
alternative = (Alternative) pe;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProblemElementKey() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new problem element key.
|
||||
*
|
||||
* @param expert expert
|
||||
* @param alternative alternative
|
||||
* @param criterion criterion
|
||||
*/
|
||||
public ProblemElementKey(Expert expert, Alternative alternative, Criterion criterion) {
|
||||
this.expert = expert;
|
||||
this.alternative = alternative;
|
||||
this.criterion = criterion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the expert.
|
||||
*
|
||||
* @return the expert
|
||||
*/
|
||||
public Expert getExpert() {
|
||||
return this.expert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alternative.
|
||||
*
|
||||
* @return the alternative
|
||||
*/
|
||||
public Alternative getAlternative() {
|
||||
return this.alternative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the criterion.
|
||||
*
|
||||
* @return the criterion
|
||||
*/
|
||||
public Criterion getCriterion() {
|
||||
return this.criterion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one of the 3 problem elements depending on the type.
|
||||
*
|
||||
* @param type the type of the problem element
|
||||
* @return the item
|
||||
*/
|
||||
public ProblemElement get(String type) {
|
||||
return this.get(type, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one of the 3 problem elements depending on the type.
|
||||
*
|
||||
* @param type the type of the problem element
|
||||
* @param next Get the next problem item. If type is ALT, get CRIT
|
||||
* @return the item
|
||||
*/
|
||||
public ProblemElement get(String type, boolean next) {
|
||||
return this.get(type, next, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one of the 3 problem elements depending on the type.
|
||||
*
|
||||
* @param type the type of the problem element
|
||||
* @param next Get the next problem item. If type is ALT, get CRIT
|
||||
* @param nextnext Get the next next problem item. If type is ALT, EXPERT
|
||||
* @return the item
|
||||
*/
|
||||
public ProblemElement get(String type, boolean next, boolean nextnext) {
|
||||
int x = -1;
|
||||
|
||||
if (Alternative.Type
|
||||
.equals(type))
|
||||
x = 0;
|
||||
else if (Expert.Type
|
||||
.equals(type))
|
||||
x = 1;
|
||||
else if (Criterion.Type
|
||||
.equals(type))
|
||||
x = 2;
|
||||
|
||||
if (next)
|
||||
x++;
|
||||
if (nextnext)
|
||||
x++;
|
||||
|
||||
x = x % 3;
|
||||
|
||||
if (x == 0)
|
||||
return this.getAlternative();
|
||||
if (x == 1)
|
||||
return this.getExpert();
|
||||
if (x == 2)
|
||||
return this.getCriterion();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object) */
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
|
||||
if (this == object)
|
||||
return true;
|
||||
|
||||
if (object == null)
|
||||
return false;
|
||||
|
||||
if (object.getClass() != this.getClass())
|
||||
return false;
|
||||
|
||||
final ProblemElementKey other = (ProblemElementKey) object;
|
||||
|
||||
EqualsBuilder eb = new EqualsBuilder();
|
||||
eb.append(this.expert, other.expert);
|
||||
eb.append(this.alternative, other.alternative);
|
||||
eb.append(this.criterion, other.criterion);
|
||||
return eb.isEquals();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode() */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder hcb = new HashCodeBuilder();
|
||||
hcb.append(this.expert);
|
||||
hcb.append(this.alternative);
|
||||
hcb.append(this.criterion);
|
||||
return hcb.toHashCode();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString() */
|
||||
@Override
|
||||
public String toString() {
|
||||
String result = ""; //$NON-NLS-1$
|
||||
|
||||
result += (this.expert != null) ? this.expert.getCanonicalName() : "null"; //$NON-NLS-1$
|
||||
result += ":"; //$NON-NLS-1$
|
||||
result += (this.alternative != null) ? this.alternative.getCanonicalName() : "null"; //$NON-NLS-1$
|
||||
result += ":"; //$NON-NLS-1$
|
||||
result += (this.criterion != null) ? this.criterion.getCanonicalName() : "null"; //$NON-NLS-1$
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object) */
|
||||
@Override
|
||||
public int compareTo(ProblemElementKey other) {/* if(!this.alternative.getName().equals(other.getAlternative().getName()))
|
||||
* return -1;
|
||||
* if(!this.criterion.getName().equals(other.getCriterion().getName())) return
|
||||
* -1; if(!this.expert.getName().equals(other.getExpert().getName())) return -1;
|
||||
* return 1; */
|
||||
return this.toString()
|
||||
.compareTo(other.toString());
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
|
||||
/**
|
||||
* The Class Alternative. Alternatives can't have parents or children.
|
||||
*/
|
||||
public class Alternative extends ProblemElement {
|
||||
|
||||
/** The Type. */
|
||||
public static String Type = Alternative.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
/** The Alternative. */
|
||||
Alternative,
|
||||
/** The Alternatives. */
|
||||
Alternatives
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new alternative.
|
||||
*/
|
||||
public Alternative(String name) {
|
||||
// super();
|
||||
setName(name);
|
||||
setType(Alternative.Type);
|
||||
updateId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* º
|
||||
* @see flintstones.problemelements.ProblemElement#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
Alternative result = new Alternative(this.getName());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#getChildren()
|
||||
*/
|
||||
@Override
|
||||
public Alternative[] getChildren() {
|
||||
return new Alternative[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#getParent()
|
||||
*/
|
||||
@Override
|
||||
public Alternative getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#hasChildren()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#hasParent()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasParent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
|
||||
/**
|
||||
* The Class Criterion.
|
||||
*/
|
||||
public class Criterion extends ProblemElement {
|
||||
|
||||
/** The cost. */
|
||||
private boolean cost;
|
||||
|
||||
/** The Type. */
|
||||
public static String Type = Criterion.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
/** n elements. */
|
||||
Criteria,
|
||||
/** 1 element. */
|
||||
Criterion,
|
||||
/** The cost. */
|
||||
cost
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new criterion.
|
||||
*/
|
||||
public Criterion(String name) {
|
||||
setName(name);
|
||||
this.setType(Criterion.Type);
|
||||
updateId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cost is cost or benefit.
|
||||
*
|
||||
* @return true, if is cost
|
||||
*/
|
||||
public boolean isCost() {
|
||||
return this.cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cost.
|
||||
*
|
||||
* @param cost the new cost
|
||||
*/
|
||||
public void setCost(boolean cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#clone() */
|
||||
@Override
|
||||
public Object clone() {
|
||||
Criterion result = new Criterion(this.getName());
|
||||
result.cost = cost;
|
||||
|
||||
ProblemElement[] children = this.getChildren();
|
||||
for (ProblemElement item : children)
|
||||
result.addChildren(item);
|
||||
|
||||
if(this.hasParent())
|
||||
result.setParent(this.parent);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
|
||||
/**
|
||||
* The Class Expert.
|
||||
*/
|
||||
public class Expert extends ProblemElement {
|
||||
|
||||
/** The Type. */
|
||||
public static String Type = Expert.class.getSimpleName();
|
||||
|
||||
/** The mail. */
|
||||
private String mail = "";
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
/** The Expert. */
|
||||
Expert,
|
||||
/** The Experts. */
|
||||
Experts,
|
||||
|
||||
/** The mail. */
|
||||
mail
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new expert.
|
||||
*/
|
||||
public Expert(String name) {
|
||||
setName(name);
|
||||
setType(Expert.Type);
|
||||
updateId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
|
||||
Expert result = new Expert(this.getName());
|
||||
result.mail = mail;
|
||||
|
||||
ProblemElement[] children = this.getChildren();
|
||||
for (ProblemElement item : children)
|
||||
result.addChildren(item);
|
||||
|
||||
if (this.hasParent())
|
||||
result.setParent(this.parent);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mail.
|
||||
*
|
||||
* @param newMail the new mail
|
||||
*/
|
||||
public void setMail(String newMail) {
|
||||
this.mail = newMail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mail.
|
||||
*
|
||||
* @return the mail
|
||||
*/
|
||||
public String getMail() {
|
||||
return mail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
|
||||
/**
|
||||
* The Class FakeProblemElement makes posible to use a dummy ProblemElement with some components.
|
||||
*/
|
||||
public class FakeProblemElement extends ProblemElement {
|
||||
|
||||
/** The Type. */
|
||||
public static String Type = FakeProblemElement.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* Instantiates a new fake problem element.
|
||||
*/
|
||||
public FakeProblemElement(String name) {
|
||||
setName(name);
|
||||
setType(FakeProblemElement.Type);
|
||||
updateId();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see flintstones.entity.problemelement.entities.ProblemElement#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* As alternative.
|
||||
*
|
||||
* @return the problem element
|
||||
*/
|
||||
public ProblemElement asAlternative() {
|
||||
this.setType(Alternative.Type);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* As criterion.
|
||||
*
|
||||
* @return the problem element
|
||||
*/
|
||||
public ProblemElement asCriterion() {
|
||||
this.setType(Criterion.Type);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* As expert.
|
||||
*
|
||||
* @return the problem element
|
||||
*/
|
||||
public ProblemElement asExpert() {
|
||||
this.setType(Expert.Type);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* As.
|
||||
*
|
||||
* @param type the type
|
||||
*/
|
||||
public ProblemElement as(String type) {
|
||||
this.setType(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateId() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
+404
@@ -0,0 +1,404 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import flintstones.entity.common.interfaces.IdentifiedEntity;
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
import flintstones.entity.problemelement.exception.DifferentProblemElementTypeException;
|
||||
|
||||
/**
|
||||
* The Class ProblemElement.
|
||||
*/
|
||||
public abstract class ProblemElement implements Comparable<ProblemElement>, IdentifiedEntity {
|
||||
|
||||
/** The children list. */
|
||||
protected LinkedList<ProblemElement> children = new LinkedList<>();
|
||||
|
||||
/** The item unique name. */
|
||||
private String name;
|
||||
|
||||
/** The parent. */
|
||||
protected ProblemElement parent = null;
|
||||
|
||||
/** The Type. */
|
||||
public static String Type; // Should be null in parent class
|
||||
|
||||
/* IdentifiedEntity implementation */
|
||||
private String serviceId = null;
|
||||
|
||||
private int order = -1;
|
||||
private int childrenOrder = 0;
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
/** The Problems. */
|
||||
Problems,
|
||||
/** The Problem. */
|
||||
Problem,
|
||||
/** The id. */
|
||||
id,
|
||||
/** The name. */
|
||||
name,
|
||||
/** The children. */
|
||||
children,
|
||||
|
||||
/** The Problem element. */
|
||||
//
|
||||
ProblemElement
|
||||
};
|
||||
|
||||
protected ProblemElement() {
|
||||
}
|
||||
|
||||
// Children modify methods
|
||||
/**
|
||||
* Adds the children.
|
||||
*
|
||||
* @param item the item
|
||||
*/
|
||||
public void addChildren(ProblemElement item) {
|
||||
|
||||
if (item.equals(this))
|
||||
return;
|
||||
|
||||
if (item.hasParent())
|
||||
item.getParent().removeChildren(item);
|
||||
|
||||
item.setParent(this);
|
||||
item.setOrder(childrenOrder++);
|
||||
children.add(item);
|
||||
}
|
||||
|
||||
public void addChildrenAfter(ProblemElement previousItem, ProblemElement item) {
|
||||
|
||||
ProblemElement[] childrenItems = getChildren();
|
||||
children.clear();
|
||||
childrenOrder = 0;
|
||||
|
||||
if (previousItem == null) {
|
||||
addChildren(item);
|
||||
for (ProblemElement child : childrenItems)
|
||||
addChildren(child);
|
||||
|
||||
} else {
|
||||
|
||||
for (ProblemElement child : childrenItems) {
|
||||
addChildren(child);
|
||||
if (previousItem.equals(child))
|
||||
addChildren(item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addChildrenBefore(ProblemElement nextItem, ProblemElement item) {
|
||||
|
||||
ProblemElement[] childrenItems = getChildren();
|
||||
children.clear();
|
||||
childrenOrder = 0;
|
||||
|
||||
for (ProblemElement child : childrenItems) {
|
||||
if (nextItem.equals(child))
|
||||
addChildren(item);
|
||||
addChildren(child);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the children.
|
||||
*
|
||||
* @param itemUniqueId the item unique id
|
||||
*/
|
||||
public void removeChildren(ProblemElement removedChild) {
|
||||
|
||||
ProblemElement[] childrenItems = getChildren();
|
||||
children.clear();
|
||||
childrenOrder = 0;
|
||||
|
||||
for (ProblemElement child : childrenItems) {
|
||||
if (child.equals(removedChild)) {
|
||||
child.setOrder(-1);
|
||||
child.setParent(null);
|
||||
continue;
|
||||
}
|
||||
addChildren(child);
|
||||
}
|
||||
//
|
||||
// for (ProblemElement child : children)
|
||||
// if (child.equals(removedChild)) {
|
||||
// children.remove(child);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent.
|
||||
*
|
||||
* @param pe the new parent
|
||||
*/
|
||||
protected void setParent(ProblemElement pe) {
|
||||
this.parent = pe;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change parent.
|
||||
*
|
||||
* @param newParent the new parent
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean changeParent(ProblemElement newParent) {
|
||||
|
||||
ProblemElement item = this;
|
||||
ProblemElement oldParent = item.getParent();
|
||||
|
||||
// Basic check
|
||||
if (item.getType().equals(Alternative.Type)) {
|
||||
return false;
|
||||
}
|
||||
// throw new AlternativeCantHaveParentException(item);
|
||||
|
||||
// Unlink from old parent
|
||||
if (oldParent != null)
|
||||
oldParent.removeChildren(item);
|
||||
|
||||
// Link with new parent
|
||||
item.setParent(newParent);
|
||||
|
||||
// Add as a child of the item
|
||||
if (newParent != null) {
|
||||
|
||||
// Basic check
|
||||
if (!item.getType().equals(newParent.getType()))
|
||||
throw new DifferentProblemElementTypeException(item, newParent);
|
||||
|
||||
newParent.addChildren(item);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setOrder(int pos) {
|
||||
order = pos;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
// END Children modify methods
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public abstract Object clone();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(ProblemElement pe) {
|
||||
return Comparator.comparing(ProblemElement::getName).thenComparing(ProblemElement::getType).compare(this, pe);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the canonical name. Parent_name > Next_parent > ... > Item_Name
|
||||
*
|
||||
* @return the canonical name
|
||||
*/
|
||||
public String getCanonicalName() {
|
||||
|
||||
if (this.parent != null) {
|
||||
if(!this.parent.getName().isEmpty()) {
|
||||
String canonicalTemplate = "{0}>{1}";
|
||||
return MessageFormat.format(canonicalTemplate, this.parent.getCanonicalName(), this.getName()).toString();
|
||||
}
|
||||
}
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets shorter item name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getShortName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the children.
|
||||
*
|
||||
* @return the children
|
||||
*/
|
||||
public ProblemElement[] getChildren() {
|
||||
return this.children.toArray(new ProblemElement[this.children.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the final elements (leaf elements) from this item.
|
||||
*
|
||||
* @return the final elements
|
||||
*/
|
||||
public ProblemElement[] getFinalElements() {
|
||||
ArrayList<ProblemElement> items = new ArrayList<>();
|
||||
|
||||
// leaf
|
||||
if (this.children.isEmpty())
|
||||
items.add(this);
|
||||
else
|
||||
for (ProblemElement child : this.children) {
|
||||
ProblemElement[] arr = child.getFinalElements();
|
||||
for (ProblemElement pe : arr)
|
||||
items.add(pe);
|
||||
}
|
||||
|
||||
return items.toArray(new ProblemElement[items.size()]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent.
|
||||
*
|
||||
* @return the parent
|
||||
*/
|
||||
public ProblemElement getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for children.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return this.children.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for parent.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean hasParent() {
|
||||
return this.parent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
// updateId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is parent.
|
||||
*
|
||||
* @return true, if is parent
|
||||
*/
|
||||
public boolean isParent() {
|
||||
return this.hasChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is leaf.
|
||||
*
|
||||
* @return true, if is leaf
|
||||
*/
|
||||
public boolean isLeaf() {
|
||||
return !isParent();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder hcb = new HashCodeBuilder();
|
||||
hcb.append(this.getId());
|
||||
hcb.append(this.getType());
|
||||
|
||||
return hcb.toHashCode();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ProblemElement)) {
|
||||
return false;
|
||||
}
|
||||
ProblemElement other = (ProblemElement) o;
|
||||
EqualsBuilder builder = new EqualsBuilder();
|
||||
builder.append(this.getId(), other.getId());
|
||||
builder.append(this.getType(), other.getType());
|
||||
|
||||
return builder.isEquals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getId() {
|
||||
return serviceId;
|
||||
};
|
||||
|
||||
@Override
|
||||
public final void updateId() {
|
||||
serviceId = calculateId();
|
||||
}
|
||||
|
||||
/* TypedEntity implementation */
|
||||
private String type;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
protected void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import flintstones.entity.problemelement.exception.InvalidProblemElementTypeException;
|
||||
|
||||
public class ProblemElementHelper {
|
||||
|
||||
public static ProblemElement create(String name, String type) {
|
||||
if(type.equals(Alternative.Type))
|
||||
return new Alternative(name);
|
||||
|
||||
if(type.equals(Expert.Type))
|
||||
return new Expert(name);
|
||||
|
||||
if(type.equals(Criterion.Type))
|
||||
return new Criterion(name);
|
||||
|
||||
if(type.equals(SortingClass.Type))
|
||||
return new SortingClass(name);
|
||||
|
||||
if(type.equals(FakeProblemElement.Type))
|
||||
return new FakeProblemElement(name);
|
||||
|
||||
throw new InvalidProblemElementTypeException(type);
|
||||
}
|
||||
|
||||
public static Alternative[] asAlternatives(ProblemElement[] pes) {
|
||||
return Arrays.stream(pes).map(k -> (Alternative)k).toArray(Alternative[]::new);
|
||||
}
|
||||
|
||||
public static Criterion[] asCriterions(ProblemElement[] pes) {
|
||||
return Arrays.stream(pes).map(k -> (Criterion)k).toArray(Criterion[]::new);
|
||||
}
|
||||
|
||||
public static Expert[] asExperts(ProblemElement[] pes) {
|
||||
return Arrays.stream(pes).map(k -> (Expert)k).toArray(Expert[]::new);
|
||||
}
|
||||
|
||||
public static SortingClass[] asSortingClasses(ProblemElement[] pes) {
|
||||
return Arrays.stream(pes).map(k -> (SortingClass)k).toArray(SortingClass[]::new);
|
||||
}
|
||||
|
||||
|
||||
public static String getNextType(String type, boolean next, boolean nextnext) {
|
||||
|
||||
int x = 0;
|
||||
|
||||
if (Alternative.Type.equals(type))
|
||||
x = 0;
|
||||
else if (Expert.Type.equals(type))
|
||||
x = 1;
|
||||
else if (Criterion.Type.equals(type))
|
||||
x = 2;
|
||||
|
||||
if (next)
|
||||
x++;
|
||||
if (nextnext)
|
||||
x++;
|
||||
|
||||
x = x % 3;
|
||||
|
||||
if (x == 0)
|
||||
return Alternative.Type;
|
||||
else if (x == 1)
|
||||
return Expert.Type;
|
||||
else if (x == 2)
|
||||
return Criterion.Type;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public static String getImage(ProblemElement pe) {
|
||||
String type = pe.getType();
|
||||
boolean isParent = pe.hasChildren();
|
||||
boolean cost = false;
|
||||
if(pe.getType().equals(Criterion.Type) && !(pe instanceof FakeProblemElement) ) {
|
||||
cost = ((Criterion)pe).isCost();
|
||||
}
|
||||
return getImage(type, isParent, cost);
|
||||
}
|
||||
|
||||
public static String getImage(String type) {
|
||||
return getImage(type, false, false);
|
||||
}
|
||||
|
||||
public static String getImage(String type, boolean parent) {
|
||||
return getImage(type, parent, false);
|
||||
}
|
||||
|
||||
public static String getImage(String type, boolean parent, boolean isCost) {
|
||||
String f = "problemelement" + File.separator;
|
||||
if(FakeProblemElement.Type.equals(type))
|
||||
return f+"fake.png";
|
||||
if (Alternative.Type.equals(type))
|
||||
return parent ? f+"alternatives.png" : f+"alternative.png";
|
||||
if (Expert.Type.equals(type))
|
||||
return parent ? f+"experts.png": f+"expert.png";
|
||||
if(SortingClass.Type.equals(type))
|
||||
return f+"sortclass.png";
|
||||
if (Criterion.Type.equals(type))
|
||||
if(parent)
|
||||
return f+"criterions.png";
|
||||
else
|
||||
return isCost ? f+"criterion_cost.png" : f+"criterion.png";
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ProblemElement[] getAsUserOrdered(ProblemElement[] pes) {
|
||||
Arrays.sort(pes, getAsUserOrderedComparator());
|
||||
return pes;
|
||||
}
|
||||
|
||||
public static ProblemElement[] getAsAlphabeticalOrdered(ProblemElement[] pes) {
|
||||
Arrays.sort(pes, getAlphabeticalComparator());
|
||||
return pes;
|
||||
}
|
||||
|
||||
// Private
|
||||
public static Comparator<ProblemElement> getAsUserOrderedComparator(){
|
||||
Comparator<ProblemElement> c = new Comparator<ProblemElement>() {
|
||||
public int compare(ProblemElement a, ProblemElement b) {
|
||||
return a.getOrder() > b.getOrder() ? 1 : -1;
|
||||
}
|
||||
|
||||
};
|
||||
return c;
|
||||
}
|
||||
|
||||
public static Comparator<ProblemElement> getAlphabeticalComparator(){
|
||||
Comparator<ProblemElement> c = new Comparator<ProblemElement>() {
|
||||
public int compare(ProblemElement o1, ProblemElement o2) {
|
||||
return transformToSInteger(o1.getName()) - transformToSInteger(o2.getName());
|
||||
}
|
||||
|
||||
int transformToSInteger(String str) {
|
||||
String number = str.replaceAll("\\D", "");
|
||||
return number.isEmpty() ? 0 : Integer.parseInt(number);
|
||||
}
|
||||
};
|
||||
return c;
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
|
||||
/**
|
||||
* The Class AHPSortClass.
|
||||
*/
|
||||
public class SortingClass extends ProblemElement{
|
||||
|
||||
/** The Type. */
|
||||
public static String Type = SortingClass.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
|
||||
/** The name. */
|
||||
name, AHPSortClass
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new AHP sort class.
|
||||
*
|
||||
* @param className the class name
|
||||
*/
|
||||
public SortingClass(String className) {
|
||||
setName(className);
|
||||
setType(SortingClass.Type);
|
||||
updateId();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see flintstones.entity.problemelement.entities.ProblemElement#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#getParent()
|
||||
*/
|
||||
@Override
|
||||
public Alternative getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#hasChildren()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.problemelements.ProblemElement#hasParent()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasParent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
package flintstones.entity.problemelement.entities;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
|
||||
/**
|
||||
* The Class AHPSortProfile.
|
||||
*/
|
||||
public class SortingProfile extends ProblemElement {
|
||||
|
||||
/** The Type. */
|
||||
public static String Type = SortingProfile.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
|
||||
/** The value. */
|
||||
value,
|
||||
/** The AHP sort profile. */
|
||||
SortingProfile,
|
||||
/** The AHP sort profiles. */
|
||||
SortingProfiles
|
||||
};
|
||||
|
||||
public static enum SortingProfileType {
|
||||
Central, Limiting
|
||||
}
|
||||
|
||||
/** The value. */
|
||||
private double value;
|
||||
|
||||
Expert expert;
|
||||
Criterion criterion;
|
||||
|
||||
/**
|
||||
* Instantiates a new AHP sort profile.
|
||||
*
|
||||
* @param limit the limit
|
||||
* @param position the position
|
||||
*/
|
||||
public SortingProfile(Expert e, Criterion c, Double limit) {
|
||||
// super();
|
||||
setType(SortingProfile.Type);
|
||||
expert = e;
|
||||
criterion = c;
|
||||
|
||||
setValue(limit);
|
||||
setName("P_" + c.getName() + "_" + e.getName() + " " + value + "");
|
||||
|
||||
updateId();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.entity.problemelement.entities.ProblemElement#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
* @param val the new value
|
||||
*/
|
||||
public void setValue(double val) {
|
||||
this.value = val;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder hcb = new HashCodeBuilder();
|
||||
hcb.append(this.getName());
|
||||
hcb.append(this.getType());
|
||||
hcb.append(this.getValue());
|
||||
hcb.append(this.expert.getName());
|
||||
hcb.append(this.criterion.getName());
|
||||
|
||||
return hcb.toHashCode();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* flintstones.entity.problemelement.entities.ProblemElement#equals(java.lang.
|
||||
* Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (!(o instanceof SortingProfile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SortingProfile other = (SortingProfile) o;
|
||||
EqualsBuilder builder = new EqualsBuilder();
|
||||
builder.append(this.getName(), other.getName());
|
||||
builder.append(this.getType(), other.getType());
|
||||
builder.append(this.getValue(), other.getValue());
|
||||
builder.append(this.expert.getName(), other.expert.getName());
|
||||
builder.append(this.criterion.getName(), other.criterion.getName());
|
||||
|
||||
return builder.isEquals();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
String template = "{1}";
|
||||
// String template = "[{0}] {1} -> {2}";
|
||||
String x = MessageFormat.format(template, Type, getName(), this.value).toString();
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculateId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public ProblemElement getExpert() {
|
||||
return expert;
|
||||
}
|
||||
|
||||
public ProblemElement getCriterion() {
|
||||
return criterion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortName() {
|
||||
return "P " + value;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package flintstones.entity.problemelement.exception;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The Class AlternativeCantHaveParentException.
|
||||
*/
|
||||
public class AlternativeCantHaveParentException extends RuntimeException {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = 1950044469539431139L;
|
||||
|
||||
/**
|
||||
* Instantiates a new alternative cant have parent exception.
|
||||
*
|
||||
* @param pe the ProblemElement
|
||||
*/
|
||||
public AlternativeCantHaveParentException(ProblemElement pe) {
|
||||
super("Alternatives can't have parent/children " + pe.getName());
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package flintstones.entity.problemelement.exception;
|
||||
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
|
||||
/**
|
||||
* The Class DifferentProblemElementTypeException.
|
||||
*/
|
||||
public class DifferentProblemElementTypeException extends RuntimeException {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = -8758298521716570202L;
|
||||
|
||||
/**
|
||||
* Instantiates a new different problem element type exception.
|
||||
*
|
||||
* @param a the a
|
||||
* @param b the b
|
||||
*/
|
||||
public DifferentProblemElementTypeException(ProblemElement a, ProblemElement b) {
|
||||
super( a.getName() + " can not be parent of " + b.getName() + ", types do not match " + a.getType() + " != " + b.getType());
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package flintstones.entity.problemelement.exception;
|
||||
|
||||
/**
|
||||
* The Class InvalidProblemElementTypeException.
|
||||
*/
|
||||
public class InvalidProblemElementTypeException extends RuntimeException {
|
||||
|
||||
/** The Constant serialVersionUID. */
|
||||
private static final long serialVersionUID = -1618577755296656641L;
|
||||
|
||||
/**
|
||||
* Instantiates a new invalid problem element type exception.
|
||||
*
|
||||
* @param type the type
|
||||
*/
|
||||
public InvalidProblemElementTypeException(String type){
|
||||
super( type + " is not a valid type for ProblemElement");
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.entity.problemelement.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings({ "javadoc", "nls" })
|
||||
public class Messages {
|
||||
|
||||
public String ALTERNATIVE_IMAGE_CHILD;
|
||||
public String ALTERNATIVE_ENTITY_NAME;
|
||||
public String ALTERNATIVE_GROUP_NAME;
|
||||
public String CRITERION_IMAGE_CHILD;
|
||||
public String CRITERION_IMAGE_COST_NEGATIVE;
|
||||
public String CRITERION_IMAGE_COST_POSITIVE;
|
||||
public String CRITERION_ENTITY_NAME;
|
||||
public String CRITERION_GROUP_NAME;
|
||||
public String CRITERION_IMAGE_PARENT;
|
||||
public String CRITERION_IMAGE_COST;
|
||||
public String EXPERT_IMAGE_CHILD;
|
||||
public String EXPERT_ENTITY_NAME;
|
||||
public String EXPERT_GROUP_NAME;
|
||||
public String EXPERT_IMAGE_PARENT;
|
||||
public String ProblemElement_canonical_template;
|
||||
public String ProblemElement_template;
|
||||
public String title_template;
|
||||
public String Profile_count;
|
||||
public String SortingClass_count;
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
ALTERNATIVE_IMAGE_CHILD=alternative.png
|
||||
ALTERNATIVE_ENTITY_NAME=Alternative
|
||||
ALTERNATIVE_GROUP_NAME=Alternatives
|
||||
CRITERION_IMAGE_CHILD=criterion.png
|
||||
CRITERION_IMAGE_COST_NEGATIVE=cost.png
|
||||
CRITERION_IMAGE_COST_POSITIVE=benefit.png
|
||||
CRITERION_GROUP_NAME=Criterion
|
||||
CRITERION_ENTITY_NAME=Criteria
|
||||
CRITERION_IMAGE_PARENT=criteria.png
|
||||
CRITERION_IMAGE_COST=type-of-criterion.png
|
||||
EXPERT_IMAGE_CHILD=expert.png
|
||||
EXPERT_ENTITY_NAME=Expert
|
||||
EXPERT_GROUP_NAME=Experts
|
||||
EXPERT_IMAGE_PARENT=group-of-experts.png
|
||||
ProblemElement_canonical_template={0}>{1}
|
||||
ProblemElement_entity=ProblemElement
|
||||
ProblemElement_template=[{0}] {1}
|
||||
ProblemElement_group=Problems
|
||||
title_template {0} | {1}
|
||||
Profile_count=The number of profiles
|
||||
SortingClass_count=The number of sorting classes
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
ALTERNATIVE_IMAGE_CHILD=alternative.png
|
||||
ALTERNATIVE_ENTITY_NAME=Alternativa
|
||||
ALTERNATIVE_GROUP_NAME=Alternativas
|
||||
CRITERION_IMAGE_CHILD=criterion.png
|
||||
CRITERION_IMAGE_COST_NEGATIVE=cost.png
|
||||
CRITERION_IMAGE_COST_POSITIVE=benefit.png
|
||||
CRITERION_GROUP_NAME=Criterios
|
||||
CRITERION_ENTITY_NAME=Criterio
|
||||
CRITERION_IMAGE_PARENT=criteria.png
|
||||
CRITERION_IMAGE_COST=type-of-criterion.png
|
||||
EXPERT_IMAGE_CHILD=expert.png
|
||||
EXPERT_ENTITY_NAME=Experto
|
||||
EXPERT_GROUP_NAME=Expertos
|
||||
EXPERT_IMAGE_PARENT=group-of-experts.png
|
||||
ProblemElement_canonical_template={0}>{1}
|
||||
ProblemElement_entity=Problema
|
||||
ProblemElement_template=[{0}] {1}
|
||||
ProblemElement_group=Problemas
|
||||
title_template {0} | {1}
|
||||
Profile_count=El número de perfiles
|
||||
SortingClass_count=El número de clases
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package flintstones.entity.problemelement.provider;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.entity.problemelement.entities.Alternative;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.Expert;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.problemelement.messages.Messages;
|
||||
|
||||
/**
|
||||
* The Class ProblemElementTitleProvider.
|
||||
*/
|
||||
public class ProblemElementTitleProvider {
|
||||
|
||||
/** The messages. */
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
/**
|
||||
* Instantiates a new problem element title provider.
|
||||
*/
|
||||
public ProblemElementTitleProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title.
|
||||
*
|
||||
* @param pe the pe
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle(ProblemElement pe) {
|
||||
String template = this.messages.title_template;
|
||||
|
||||
String type = pe.getType();
|
||||
String label = ""; //$NON-NLS-1$
|
||||
|
||||
if (type.equals(Alternative.Type))
|
||||
label = this.messages.ALTERNATIVE_ENTITY_NAME;
|
||||
else if (type.equals(Criterion.Type))
|
||||
label = this.messages.CRITERION_ENTITY_NAME;
|
||||
else if (type.equals(Expert.Type))
|
||||
label = this.messages.EXPERT_ENTITY_NAME;
|
||||
|
||||
String message = MessageFormat.format(template, label, pe.getCanonicalName());
|
||||
return message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user