public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -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,14 @@
<?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.preferences.preferencecollection</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Preferencecollection</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.entity.preferences.preferencecollection</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.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>1779484362571</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,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Preferencecollection
Bundle-SymbolicName: flintstones.entity.preferences.preferencecollection
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.entity.preferences.preferencecollection
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: flintstones.entity.preferences.preferencecollection
Require-Bundle: flintstones.entity.problemelement,
flintstones.entity.ahppreferences,
flintstones.entity.ahp,
flintstones.entity.extensionenum,
flintstones.entity.domain,
flintstones.helper.data
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,360 @@
package flintstones.entity.preferences.preferencecollection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import flintstones.entity.ahp.AHPMatrix;
import flintstones.entity.ahppreferences.PreferenceBuild;
import flintstones.entity.ahppreferences.PreferenceCollectionKey;
import flintstones.entity.ahppreferences.PreferenceMatrix;
import flintstones.entity.extensionenum.ExtensionEnum;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.helper.data.HashMatrix;
/**
* The Class PreferenceCollection.
*/
public class PreferenceCollection {
/**
* Instantiates a new preference collection. Esta clase almacena conjuntos de
* comparaciones dados 4 tipos. Los 2 primeros tipos, normalmente experto y
* criterio están en los combos. El tercer tipo es el elemento de la izquierda
* de la comparación. El cuarto tipo es el elemento de la derecha de la
* comparación. Los tipos 1,2 no pueden cambiar, aunque pueden ser "genericos".
* Los tipos 3,4 pueden cambiar cuando se cambien el tipo 1 o 2. No pueden ser
* genericos.
*
* Esta clase no almacena matrices AHP, almacena las comparaciones y a partir de
* las comparaciones se sacan AHP o no.
*
* El orden de tipo1, tipo2 en principio no importa y viene determinado por el
* orden los propios elementos de problema.
*/
public PreferenceCollection() {
}
/** The content. */
private HashMatrix<ProblemElement, ProblemElement, PreferenceBuild> content = new HashMatrix<>();
/** The any build. */
private PreferenceBuild anyBuild;
/** The main elements. */
private HashMap<String, ProblemElement> mainElements = new HashMap<>();
/** The other elements. */
private HashMap<String, ProblemElement> otherElements = new HashMap<>();
/**
* The Enum Fields.
*/
public static enum Fields implements ExtensionEnum {
/** The Preference collections. */
PreferenceCollections,
/** The Preference collection. */
PreferenceCollection,
/** The main type. */
mainType,
/** The other type. */
otherType,
/** The left type. */
leftType,
/** The right type. */
rightType
};
/**
* Instantiates a new preference collection.
*
* @param builds the builds
*/
public PreferenceCollection(PreferenceBuild[] builds) {
anyBuild = builds[0];
for (PreferenceBuild build : builds) {
content.put(build.getMain(), build.getOther(), build);
mainElements.put(build.getMain().getName(), build.getMain());
otherElements.put(build.getOther().getName(), build.getOther());
}
}
/**
* Sets the value.
*
* @param main the main PE (first dropwdown)
* @param other the other PE (second dropdown)
* @param left the left PE (left column)
* @param right the right PE (right column)
* @param index the index
*/
public void set(ProblemElement main, ProblemElement other, ProblemElement left, ProblemElement right, int index) {
PreferenceMatrix matrix = content.get(main, other).getMatrix();
matrix.set(left, right, index);
}
/**
* Gets the builds the.
*
* @param main the main
* @param other the other
* @return the builds the
*/
public PreferenceBuild getBuild(ProblemElement main, ProblemElement other) {
return content.get(main, other);
}
/**
* Gets the.
*
* @param main the main
* @param other the other
* @return the int[][]
*/
public int[][] get(ProblemElement main, ProblemElement other) {
PreferenceBuild build = getBuild(main, other);
if (build == null)
return null;
return build.getMatrix().getMatrix();
}
/**
* Gets the.
*
* @param main the main
* @param other the other
* @param left the left
* @param right the right
* @return the int
*/
public int get(ProblemElement main, ProblemElement other, ProblemElement left, ProblemElement right) {
PreferenceMatrix matrix = content.get(main, other).getMatrix();
return matrix.get(left, right);
}
/**
* Gets the main element.
*
* @param name the name
* @return the main element
*/
public ProblemElement getMainElement(String name) {
return mainElements.get(name);
}
/**
* Gets the other element.
*
* @param name the name
* @return the other element
*/
public ProblemElement getOtherElement(String name) {
return otherElements.get(name);
}
/**
* Gets the all main elements.
*
* @return the all main elements
*/
public ProblemElement[] getAllMainElements() {
return mainElements.values().toArray(new ProblemElement[0]);
}
/**
* Gets the all other elements.
*
* @return the all other elements
*/
public ProblemElement[] getAllOtherElements() {
return otherElements.values().toArray(new ProblemElement[0]);
}
/**
* Gets the every AHP matrix.
*
* @return the every AHP matrix
*/
// AHP
public AHPMatrix[] getEveryAHPMatrix() {
return getEveryAHPMatrix(anyBuild.getMain());
}
/**
* Gets the every AHP matrix.
*
* @param main the main
* @return the every AHP matrix
*/
public AHPMatrix[] getEveryAHPMatrix(ProblemElement main) {
ProblemElement[] others = getAllOtherElements();
AHPMatrix[] matrixes = new AHPMatrix[others.length];
for (int i = 0; i < others.length; i++) {
ProblemElement other = others[i];
AHPMatrix matrix = getAHPMatrix(main, other);
matrixes[i] = matrix;
}
return matrixes;
}
/**
* Gets the every AHP matrix other.
*
* @param other the other
* @return the every AHP matrix other
*/
public AHPMatrix[] getEveryAHPMatrixOther(ProblemElement other) {
ProblemElement[] mains = getAllMainElements();
AHPMatrix[] matrixes = new AHPMatrix[mains.length];
for (int i = 0; i < mains.length; i++) {
ProblemElement main = mains[i];
AHPMatrix matrix = getAHPMatrix(main, other);
matrixes[i] = matrix;
}
return matrixes;
}
/**
* Gets the AHP matrix.
*
* @return the AHP matrix
*/
public AHPMatrix getAHPMatrix() {
if (mainElements.size() != 1)
throw new RuntimeException(
"mainArr should have exactly one element to use this API. (The generic ProblemElement) ");
if (otherElements.size() != 1)
throw new RuntimeException(
"otherArr should have exactly one element to use this API. (The generic ProblemElement) ");
return getAHPMatrix(mainElements.values().iterator().next(), otherElements.values().iterator().next());
}
/**
* Gets the AHP matrix.
*
* @param main the main
* @param other the other
* @return the AHP matrix
*/
public AHPMatrix getAHPMatrix(ProblemElement main, ProblemElement other) {
if (main == null && other == null)
throw new RuntimeException("API abuse");
if (main == null)
main = mainElements.values().iterator().next();
if (other == null)
other = otherElements.values().iterator().next();
PreferenceBuild build = content.get(main, other);
PreferenceMatrix matrix = build.getMatrix();
if (!build.isAHP())
throw new RuntimeException(
"AHPMatrix can not be generated if you are not comparing element with the same type ");
return matrix.getAHPMatrix();
}
/**
* Gets the AHP content for.
*
* @param main the main
* @param other the other
* @return the AHP content for
*/
public AHPMatrix[] getAHPMatrixesFor(ProblemElement main, ProblemElement other) {
PreferenceBuild build = content.get(main, other);
LinkedList<ProblemElement> leftArr = build.getLeftElements();
LinkedList<ProblemElement> rightArr = build.getRightElements();
ArrayList<AHPMatrix> matrixArr = new ArrayList<>();
for (ProblemElement left : leftArr) {
ProblemElement[] all = new ProblemElement[1 + rightArr.size()];
int i = 0;
all[i++] = left;
for (ProblemElement right : rightArr)
all[i++] = right;
AHPMatrix matrix = new AHPMatrix(all);
for (int j = 1; j < all.length; j++) {
matrix.set(left, all[j], build.get(left, all[j]));
}
matrixArr.add(matrix);
}
return matrixArr.toArray(new AHPMatrix[0]);
}
/**
* Gets the key.
*
* @return the key
*/
public PreferenceCollectionKey getKey() {
return anyBuild.getKey();
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (Entry<ProblemElement, HashMap<ProblemElement, PreferenceBuild>> entry1 : content.entrySet()) {
sb.append("P1 " + entry1.getKey().toString());
for (Entry<ProblemElement, PreferenceBuild> entry2 : entry1.getValue().entrySet()) {
sb.append("\n");
sb.append("P2 " + entry2.getKey().toString());
sb.append("\n");
sb.append(entry2.getValue().toString());
}
sb.append("\n");
}
return sb.toString();
}
/**
* Gets the builds.
*
* @return the builds
*/
public ArrayList<PreferenceBuild> getBuilds() {
ArrayList<PreferenceBuild> builds = new ArrayList<>();
for (HashMap<ProblemElement, PreferenceBuild> entry : content.values())
for (PreferenceBuild build : entry.values())
builds.add(build);
return builds;
}
}