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.application.debug</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Debug</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.application.debug</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>1779484362514</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,44 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Debug
Bundle-SymbolicName: flintstones.application.debug;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.application.debug
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: flintstones.helper.data,
javax.inject,
flintstones.model.problemelement.service,
flintstones.model.valuation.service,
flintstones.entity.valuation,
flintstones.entity.problemelement,
flintstones.application.constants,
flintstones.model.domain.ui.service,
org.eclipse.e4.core.contexts,
flintstones.model.domain.service,
flintstones.domain.fuzzyset,
org.apache.commons.lang,
flintstones.model.ahppreferences.service,
flintstones.model.application.service,
flintstones.model.ahpsort.profileassignment.service,
flintstones.operator,
flintstones.valuation.ui,
org.eclipse.e4.ui.workbench,
org.eclipse.e4.core.di,
org.eclipse.jface,
javax.annotation,
flintstones.model.method.service,
flintstones.model.method.phase.service,
flintstones.entity.method.phase.ui,
org.eclipse.e4.ui.model.workbench,
flintstones.model.ahp.referencepoint.service,
flintstones.helper.debug,
flintstones.model.engine.r.service,
flintstones.entity.method.phase,
flintstones.entity.method,
flintstones.domain.numeric.integer,
flintstones.valuation.linguistic,
flintstones.valuation.hesitant,
flintstones.valuation.numeric.real,
flintstones.valuation.numeric.integer
Import-Package: org.eclipse.core.runtime
Export-Package: flintstones.application.debug.handler
@@ -0,0 +1,3 @@
# Wenas info
![imagen](borrar/tpr.jpg)
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
borrar/
@@ -0,0 +1,89 @@
package flintstones.application.debug.addon;
import java.util.Arrays;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.application.model.IApplicationService;
import flintstones.helper.data.text.DebugStream;
import flintstones.helper.debug.DH;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.domain.ui.service.IDomainUIService;
import flintstones.model.engine.r.service.IREngineService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.operator.service.IOperatorService;
// Importante:
// 1 - Nada de javadoc aqui.
// 2 - El cdigo que se quede aqui debe poder borrarse y que todo funcione.
// 3 - Usar solo para pruebas
// 4 - No tocar init ni el constructor. Colocad el programa/prueba en auto()
@SuppressWarnings({ "nls", "javadoc" })
public class AutoAddon {
@Inject
IEclipseContext context;
@Inject
IApplicationService appService;
@Inject
IValuationService valuationService;
@Inject
IDomainService domainService;
@Inject
IDomainUIService domainUI;
@Inject
IOperatorService operatorService;
@Inject
IProblemElementService problemService;
@Inject
IREngineService rService;
public AutoAddon() {
}
@PostConstruct
public void init(IEclipseContext context) {
String[] args = Platform.getCommandLineArgs();
if (Arrays.asList(args).stream().anyMatch(flag -> flag.equals("-autoAddon"))) {
DH.out("!INFO Ejecutando AutoAddon ya que -autoAddon esta presente");
this.auto(context);
}
if (Arrays.asList(args).stream().anyMatch(flag -> flag.equals("-autoSystemOut"))) {
DH.out("!INFO Mejorando System.Out.Print ya que -autoSystemOut esta presente");
DebugStream.activate();
}
// DH.hide("router");
DH.hide("router");
// DH.hide("I/O");
DH.hide("locale");
}
public void auto(IEclipseContext context) {
// ContextInjectionFactory.make(ExecuteDebugHandler.class, context).execute();
// BrowserShell shell = new BrowserShell();
// SvgBrowser br = new SvgBrowser(shell.get());
// br.setCanvas(new SortingDiagram());
// shell.setWidget(br);
// br.render();
//
// shell.open();
}
}
@@ -0,0 +1,36 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import flintstones.application.model.IApplicationService;
import flintstones.application.model.ProblemType;
public class ChangeProblemTypeHandler {
@Inject
IApplicationService appService;
@Inject
EModelService modelService;
@Inject
MApplication application;
@Execute
public void execute() {
ProblemType type = appService.getProblemType();
type = type.equals(ProblemType.Ranking) ? ProblemType.Sorting : ProblemType.Ranking;
appService.launchProblem(type);
// MUIElement uiElement = (MUIElement) modelService.find(ApplicationContants.MHandledToolItem_Change_Problem_Type, this.application); // $NON-NLS-1$
// MHandledToolItem item = (MHandledToolItem)uiElement;
// item.setLabel(type.toString() + " Problem");
}
}
@@ -0,0 +1,49 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import flintstones.application.constants.FrameworkConstants;
import flintstones.helper.debug.DH;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.valuation.service.IValuationService;
@SuppressWarnings("javadoc")
public class ClearDomainDebugHandler {
/** The broker. */
@Inject
IEventBroker broker;
/** The context. */
@Inject
IEclipseContext context;
@Inject
IDomainService domainService;
@Inject
IValuationService valuationService;
@Execute
public void execute() {
DH.out("[DEBUG] Eliminando todos los dominios" );
domainService.clear();
valuationService.clear();
sendEvents();
}
private void sendEvents() {
this.broker.post(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_DELETED, null);
this.broker.post(FrameworkConstants.TOPIC_VALUATION_DELETED, null);
}
}
@@ -0,0 +1,72 @@
package flintstones.application.debug.handler;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.helper.debug.DH;
@SuppressWarnings("javadoc")
public class DumpExtensionPointDataDebugHandler {
@Execute
public void execute() {
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint[] extensionPoints = extensionRegistry.getExtensionPoints();
DH.l(5);
DH.out(" MOSTRANDO PUNTOS DE EXTENSIÓN");
DH.out(" RECOMENDADO PEGAR TODO EN UN EDITOR DE TEXTO");
DH.out(" Y FORMATEAR COMO YAML");
DH.l(2);
for(IExtensionPoint extensionPoint : extensionPoints) {
if(extensionPoint.getUniqueIdentifier().contains("flintstones")) {
show(extensionPoint);
DH.l(2);
}
}
}
private void show(IExtensionPoint extensionPoint) {
DH.out("IDENTIFICADOR " + extensionPoint.getUniqueIdentifier() + " ==================================== :" );
// LEVEL 1 - El de eclipse. Tiene X atributos, almenos uno debe ser nuestro.
IExtension[] extensions = extensionPoint.getExtensions();
for(IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for( IConfigurationElement configElement : configurationElements ) {
showConfig(configElement,2);
DH.out("");
}
}
}
private void showConfig(IConfigurationElement configElement, int level) {
String indentText = new String(new char[level-1]).replace("\0", " ");
DH.out(indentText + configElement.getName()+":");
// LEVEL 2 - AQUí ESTAN NUESTROS VALORES
String[] atributes = configElement.getAttributeNames();
indentText = new String(new char[level]).replace("\0", " ");
for( String atribute : atributes ) {
DH.out( indentText + atribute + " : " + configElement.getAttribute(atribute));
}
// Si hay sub-valores, recursividad
IConfigurationElement[] children = configElement.getChildren();
if( children.length > 0 ) {
for( IConfigurationElement subConfig : children ) {
showConfig(subConfig, level +1);
}
}
}
}
@@ -0,0 +1,59 @@
package flintstones.application.debug.handler;
import java.util.HashMap;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.entity.method.Method;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.helper.data.text.ClassToString;
import flintstones.helper.debug.DH;
import flintstones.model.method.phase.IPhaseMethodService;
import flintstones.model.method.service.IMethodService;
@SuppressWarnings("javadoc")
public class DumpPhasesOutputDebugHandler {
@Inject
IPhaseMethodService phaseService;
@Inject
IMethodService methodService;
@Execute
public void execute() {
DH.l();
PhaseMethodUI[] phases = phaseService.getAll();
for (PhaseMethodUI phase : phases) {
DH.out("===== Export " + phase.getModel().getName() + "(" + phase.getPosition() + ")" + " - "
+ phase.getModel().getId());
DH.out(phase.getModel().getExportedSummary() + "\n");
}
DH.l(3);
for(Method m : methodService.getAll()) {
HashMap<String, Object> data = m.getExportedData();
DH.out("===== Export " + m.getName() + " - "+ m.getId());
for(Entry<String,Object> entry : data.entrySet()) {
String key = entry.getKey();
String value = ClassToString.getClassAsString(entry.getValue());
DH.out(key + " => " + value);
}
}
DH.l();
}
}
@@ -0,0 +1,83 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
import flintstones.helper.debug.DH;
import flintstones.model.ahp.referencepoint.service.IReferencePointService;
import flintstones.model.ahppreferences.service.IProblemPreferencesService;
import flintstones.model.ahpsort.profileassignment.service.IProfileAssignmentService;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.domain.ui.service.IDomainUIService;
import flintstones.model.method.phase.IPhaseMethodService;
import flintstones.model.method.service.IMethodService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.operator.service.IOperatorService;
import flintstones.valuation.ui.service.IValuationUIService;
@SuppressWarnings("javadoc")
public class DumpServicesDebugHandler {
@Inject
IProblemElementService problemService;
@Inject
IDomainService domainService;
@Inject
IDomainUIService uiDomainService;
@Inject
IValuationService valuationService;
@Inject
IValuationUIService valuationUIService;
@Inject
IOperatorService operatorService;
@Inject
IMethodService methodService;
@Inject
IPhaseMethodService phaseService;
@Inject
IApplicationService appService;
@Inject
IProblemPreferencesService ppService;
@Inject
IProfileAssignmentService profileService;
@Inject
IReferencePointService referencePointService;
@Execute
public void execute() {
show(problemService, "problemService");
show(domainService, "domainService");
show(valuationService, "valuationService");
show(appService, "appService");
show(methodService, "methodService");
show(phaseService, "phaseService");
show(ppService, "problemPreferencesService");
show(profileService, "profileService");
show(referencePointService, "referencePointService");
}
private void show(Object service, String name) {
String preText = "========= " + name + " =========\n";
String text = service.toString();
String postText = "\n\n";
DH.out(preText + text + postText);
}
}
@@ -0,0 +1,136 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import flintstones.application.model.IApplicationService;
import flintstones.application.model.ProblemType;
import flintstones.model.ahpsort.profileassignment.service.IProfileAssignmentService;
import flintstones.model.problemelement.service.IProblemElementService;
@SuppressWarnings("javadoc")
public class ExecuteDebugHandler {
@Inject
IEclipseContext context;
@Inject
IProblemElementService problemService;
@Inject
EModelService modelService;
@Inject
MApplication application;
@Inject
EPartService partService;
@Inject
IApplicationService appService;
@Inject
IProfileAssignmentService profileService;
@Execute
public void execute() {
// ahpService.unregister("AHPAlternativeRatingPart");
// ahpService.register("Title",
// "flintstones.domain.ahp",
// "flintstones.application.perspective.gathering.ahp.ui",
// "flintstones.application.perspective.gathering.ahp.ui",
// "AHPAlternativeRatingPart");
//
// ProblemElement[] experts = problemService.getAll(Expert.Type);
// ProblemElement[] crits = problemService.getAll(Criterion.Type);
//
// if(experts.length > 0 && crits.length > 0) {
//
// Expert e = (Expert) experts[0];
// Criterion c = (Criterion) crits[0];
// ProfileAssignment pas = profileService.get(e, c);
//
// BrowserShell shell = new BrowserShell();
// SvgBrowser br = new SvgBrowser(shell.get());
//
// SortingDiagram diagram = new SortingDiagram();
// AHPSortProfile p;
// diagram.setProfiles(pas.getAllProfiles());
// br.setCanvas(diagram);
// shell.setWidget(br);
// br.render();
//
// shell.open();
//
// }
ProblemType type = appService.getProblemType();
type = type.equals(ProblemType.Ranking) ? ProblemType.Sorting : ProblemType.Ranking;
appService.launchProblem(type);
// int x = 0;
//
// BrowserShell shell = new BrowserShell();
//
// SvgChart chart = new SvgChart(1666, 1000, 1, 1);
// SvgBrowser br = new SvgBrowser(shell.get(), chart);
//
// double min = 0.0;
// double max = 1.0;
//
// LineSeries redSeries = new LineSeries();
// for(int i = 0; i < 11; i++) {
//
// Random r = new Random();
// double a = (double)i/10;
// double b = min + (max - min) * r.nextDouble();
//
// redSeries.add(a, b);
//
// }
// redSeries.setColor("#ff0000");
// redSeries.showLegend(true);
// redSeries.showMarkers(true);
//
// // lines
// double[][] points = new double[4][2];
// points[0][0] = .10;
// points[0][1] = .10;
// points[1][0] = .20;
// points[1][1] = .20;
// points[2][0] = .30;
// points[2][1] = .30;
// points[3][0] = .40;
// points[3][1] = .15;
//
// LineSeries series = new LineSeries(points);
// series.setColor("#0000ff");
// series.showLegend(false);
//
// chart.drawLineSeries(series);
// chart.drawLineSeries(redSeries);
// chart.drawMarkers(false, false, 0.1);
//
// shell.setWidget(br);
// br.render();
//
// shell.open();
}
}
@@ -0,0 +1,262 @@
package flintstones.application.debug.handler;
import java.io.FileWriter;
import java.io.IOException;
import javax.inject.Inject;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import flintstones.domain.fuzzyset.FuzzySet;
import flintstones.domain.fuzzyset.function.types.TrapezoidalFunction;
import flintstones.domain.fuzzyset.label.LabelLinguisticDomain;
import flintstones.domain.numeric.integer.NumericIntegerDomain;
import flintstones.domain.numeric.real.NumericRealDomain;
import flintstones.entity.domain.Domain;
import flintstones.entity.problemelement.ProblemElementKey;
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.valuation.Valuation;
import flintstones.model.domain.service.IDomainService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
import flintstones.valuation.hesitant.HesitantValuation;
import flintstones.valuation.linguistic.LinguisticValuation;
import flintstones.valuation.numeric.integer.IntegerValuation;
import flintstones.valuation.numeric.real.RealValuation;
public class ExportToAFRYCA {
private static final String AFRYCA_INTEGER_DOMAIN = "afryca.domain.integer";
private static final String AFRYCA_REAL_DOMAIN = "afryca.domain.real";
private static final String AFRYCA_LINGUISTIC_DOMAIN = "afryca.domain.fuzzyset";
private static final String AFRYCA_STRUCTURE = "afryca.decisionmatrix";
private static final String[] FILTER_NAMES = { "AFRYCA files (*.afryca)" }; //$NON-NLS-1$
private static final String[] FILTER_EXTS = { "*.afryca" }; //$NON-NLS-1$
private static final String SEMICOLON = ";";
public static final String SEPARATOR = "_SEPARATOR_";
@Inject
IProblemElementService problemService;
@Inject
private IDomainService domainService;
@Inject
private IValuationService valuationService;
@Execute
public void execute() {
try {
export();
} catch (IOException | XMLStreamException e) {
e.printStackTrace();
}
}
private void export() throws IOException, XMLStreamException {
FileDialog dlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
dlg.setFilterNames(FILTER_NAMES);
dlg.setFilterExtensions(FILTER_EXTS);
String fileName = dlg.open();
if(fileName != null)
write(fileName);
}
private void write(String fileName) throws IOException, XMLStreamException {
XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileWriter(fileName));
streamWriter.writeStartElement("gdmp"); //$NON-NLS-1$
streamWriter.writeStartElement("file"); //$NON-NLS-1$
streamWriter.writeEndElement(); //$NON-NLS-1$
writeExperts(streamWriter);
writeCriteria(streamWriter);
writeAlternatives(streamWriter);
writeDomains(streamWriter);
writeStructure(streamWriter);
writePreferences(streamWriter);
writeDomainsStructures(streamWriter);
streamWriter.writeEndElement();
streamWriter.writeEndDocument();
streamWriter.flush();
streamWriter.close();
}
private void writeExperts(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("experts"); //$NON-NLS-1$
for(ProblemElement e: problemService.getSubElements(Expert.Type)) {
streamWriter.writeStartElement("expert");//$NON-NLS-1$
streamWriter.writeCharacters(e.getName());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
private void writeCriteria(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("criteria"); //$NON-NLS-1$
for(ProblemElement c: problemService.getSubElements(Criterion.Type)) {
streamWriter.writeStartElement("criterion");//$NON-NLS-1$
streamWriter.writeCharacters(c.getName());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
private void writeAlternatives(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("alternatives"); //$NON-NLS-1$
for(ProblemElement a: problemService.getAll(Alternative.Type)) {
streamWriter.writeStartElement("alternative");
streamWriter.writeCharacters(a.getName());
streamWriter.writeEndElement();
}
streamWriter.writeEndElement(); //$NON-NLS-1$
}
private void writeDomains(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("domains"); //$NON-NLS-1$
for(Domain d: domainService.getAll()) {
streamWriter.writeStartElement("domain");
if(d instanceof NumericIntegerDomain) {
streamWriter.writeCharacters(AFRYCA_INTEGER_DOMAIN);
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.getName());
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.toString());
} else if(d instanceof NumericRealDomain) {
streamWriter.writeCharacters(AFRYCA_REAL_DOMAIN);
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.getName());
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.toString());
} else if(d instanceof FuzzySet) {
streamWriter.writeCharacters(AFRYCA_LINGUISTIC_DOMAIN);
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(d.getName());
streamWriter.writeCharacters(SEMICOLON);
streamWriter.writeCharacters(toStringLinguisticDomain((FuzzySet) d));
}
streamWriter.writeEndElement();
}
streamWriter.writeEndElement();
}
private String toStringLinguisticDomain(FuzzySet domain) {
String result = ""; //$NON-NLS-1$
int cardinality = domain.getLabelSet().getCardinality();
if(cardinality > 0) {
for(int i = 0; i < cardinality; ++i) {
if(i > 0) {
result += "separator"; //$NON-NLS-1$
}
result += "[" + toStringLabel(domain.getLabelSet().getLabels().get(i)) + ";" + domain.getValues().get(i) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
return result;
}
private String toStringLabel(LabelLinguisticDomain label) {
return label.getName() + ";" + toStringSemantic((TrapezoidalFunction) label.getSemantic());
}
private String toStringSemantic(TrapezoidalFunction semantic) {
return ("Trapezoidal(" + semantic.getLimits()[0] + ", " + semantic.getLimits()[1] + ", " +
semantic.getLimits()[2] + ", " + semantic.getLimits()[3] + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
private void writeStructure(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("structure");
streamWriter.writeCharacters(AFRYCA_STRUCTURE);
streamWriter.writeEndElement();
}
private void writePreferences(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("preferences");
double value;
LabelLinguisticDomain label;
ProblemElement exp, alt, crit;
for(int expert = 0; expert < problemService.getSubElements(Expert.Type).length; ++expert) {
exp = problemService.getSubElements(Expert.Type)[expert];
for(int row = 0; row < problemService.getSubElements(Criterion.Type).length; ++row) {
streamWriter.writeStartElement("preference");
crit = problemService.getSubElements(Criterion.Type)[row];
for(int col = 0; col < problemService.getAll(Alternative.Type).length; ++col) {
alt = problemService.getAll(Alternative.Type)[col];
ProblemElementKey pek = new ProblemElementKey((Expert) exp, (Alternative) alt, (Criterion) crit);
Valuation v = valuationService.getValuationFor(pek);
if(v instanceof IntegerValuation) {
value = ((IntegerValuation) v).getValue();
streamWriter.writeCharacters(Integer.toString((int) value));
} else if(v instanceof RealValuation) {
value = ((RealValuation) v).getValue();
streamWriter.writeCharacters(Double.toString(value));
} else if(v instanceof LinguisticValuation) {
label = ((LinguisticValuation) v).getLabel();
streamWriter.writeCharacters(label.getName());
} else if(v instanceof HesitantValuation) {
streamWriter.writeCharacters(toStringAFRYCA((HesitantValuation) v));
}
if(col != problemService.getAll(Alternative.Type).length - 1)
streamWriter.writeCharacters(",");
}
streamWriter.writeEndElement();
}
}
streamWriter.writeEndElement();
}
public String toStringAFRYCA(HesitantValuation v) {
if (v.isPrimary()) {
return v.getLabel().toString();
} else if (v.isUnary()) {
return (v.getUnaryRelation().toString() + SEPARATOR + v.getTerm()); //$NON-NLS-1$
} else if (v.isBinary()) {
return ("Between" + SEPARATOR + v.getLowerTerm() + SEPARATOR + "and" + SEPARATOR + v.getUpperTerm());
} else {
return " "; //$NON-NLS-1$
}
}
private void writeDomainsStructures(XMLStreamWriter streamWriter) throws XMLStreamException {
streamWriter.writeStartElement("domains_structures");
ProblemElement exp, alt, crit;
for(int expert = 0; expert < problemService.getSubElements(Expert.Type).length; ++expert) {
exp = problemService.getSubElements(Expert.Type)[expert];
for(int row = 0; row < problemService.getSubElements(Criterion.Type).length; ++row) {
streamWriter.writeStartElement("domain_structure");
crit = problemService.getSubElements(Criterion.Type)[row];
for(int col = 0; col < problemService.getAll(Alternative.Type).length; ++col) {
alt = problemService.getAll(Alternative.Type)[col];
ProblemElementKey pek = new ProblemElementKey((Expert) exp, (Alternative) alt, (Criterion) crit);
Valuation v = valuationService.getValuationFor(pek);
streamWriter.writeCharacters(v.getDomain().getName());
if(col != problemService.getAll(Alternative.Type).length - 1)
streamWriter.writeCharacters("separator");
}
streamWriter.writeEndElement();
}
}
streamWriter.writeEndElement();
}
}
@@ -0,0 +1,25 @@
package flintstones.application.debug.handler;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.model.method.phase.IPhaseMethodService;
@SuppressWarnings("javadoc")
public class FillOperatorsAggregation {
@Inject
IPhaseMethodService phaseService;
@Inject
IEventBroker broker;
@Execute
public void execute() {
System.err.println("Hay que rehacerlo");
broker.post(PhaseMethodUI.REFRESH_SUB_ID, null);
}
}
@@ -0,0 +1,87 @@
package flintstones.application.debug.handler;
import java.util.Arrays;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.services.events.IEventBroker;
import flintstones.application.constants.FrameworkConstants;
import flintstones.entity.problemelement.ProblemElementKey;
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.valuation.Valuation;
import flintstones.model.method.phase.IPhaseMethodService;
import flintstones.model.problemelement.service.IProblemElementService;
import flintstones.model.valuation.service.IValuationService;
@SuppressWarnings("javadoc")
public class FillValuationsDebugHandler {
@Inject
IPhaseMethodService phaseService;
@Inject
IEventBroker broker;
@Inject
IProblemElementService problemService;
@Inject
IValuationService valuationService;
Valuation[] valuations;
@Execute
public void execute() {
fill();
sendEvents();
}
private void fill() {
valuations = Arrays.stream(valuationService.getAll()).filter( k -> k.isEvaluated()).toArray(Valuation[]::new);
ProblemElement[] criterions = problemService.getSubElements(Criterion.Type);
ProblemElement[] experts = problemService.getSubElements(Expert.Type);
ProblemElement[] alternatives = problemService.getAll(Alternative.Type);
fillValuations(criterions, experts, alternatives);
}
private void fillValuations(ProblemElement[] cs, ProblemElement[] es, ProblemElement[] as) {
for(ProblemElement c : cs )
for(ProblemElement e : es )
for(ProblemElement a : as ) {
ProblemElementKey pek = new ProblemElementKey((Expert)e, (Alternative)a, (Criterion)c);
if(valuationService.getValuationFor( pek ) == null || !valuationService.getValuationFor(pek).isEvaluated() )
fillWithRandomValuation(c,e,a);
}
}
private void fillWithRandomValuation(ProblemElement c, ProblemElement e, ProblemElement a) {
if(valuations.length == 0)
throw new RuntimeException("Es necesario tener al menos 1 evaluación puesta. Se elige al azar entre las disponibles");
int rnd = (int) (Math.random() * valuations.length) + 1;
Valuation v = valuations[rnd-1];
ProblemElementKey pek = new ProblemElementKey((Expert)e, (Alternative)a, (Criterion)c);
valuationService.addOrUpdate(pek, v);
}
private void sendEvents() {
this.broker.post(FrameworkConstants.TOPIC_FRAMEWORK_PROBLEMELEMENT_CREATED, FrameworkConstants.empty() );
this.broker.post(FrameworkConstants.TOPIC_FRAMEWORK_DOMAIN_CREATED, null);
this.broker.post(FrameworkConstants.TOPIC_VALUATION_CREATED, null);
}
}
@@ -0,0 +1,31 @@
package flintstones.application.debug.handler;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.application.model.IApplicationService;
@SuppressWarnings("javadoc")
public class OpenSaveFileDebugHandler {
@Inject
IApplicationService appService;
@Execute
public void execute() {
String fileName = appService.getSavePath();
File f = new File(fileName);
try {
Desktop.getDesktop().open(f);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,117 @@
package flintstones.application.debug.handler;
import java.lang.reflect.Field;
import java.util.HashMap;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import flintstones.application.constants.ApplicationContants;
import flintstones.application.constants.FrameworkConstants;
import flintstones.helper.data.Pair;
import flintstones.helper.data.PairList;
import flintstones.helper.debug.DH;
@SuppressWarnings("javadoc")
public class SendBrokerDebugHandler {
@Inject
IEventBroker broker;
@Inject
MApplication application;
@Inject
EModelService modelService;
@Inject
MApplication app;
MMenu menu;
@Execute
public void execute(@Optional ParameterizedCommand command) {
@SuppressWarnings("unchecked")
HashMap<String, String> map = (HashMap<String, String>) command.getParameterMap();
String eventID = map.get(ApplicationContants.MParameter_General_Sendbroker);
// Change selected method
DH.out("Lanzado evento " + eventID);
broker.send(eventID, null);
}
@PostConstruct
private void postConstruct() {
buildMenu();
}
private void buildMenu() {
String commandId = ApplicationContants.MCommand_General_Sendbroker;
String menuId = ApplicationContants.MMenu_Sendbroker;
String windowId = ApplicationContants.MWindow_Main;
MWindow window = (MWindow) this.modelService.find(windowId, this.application);
MCommand command = modelService.findElements(app, commandId, MCommand.class, null).get(0);
MMenu mainMenu = window.getMainMenu();
menu = (MMenu) mainMenu.getChildren().stream().filter(k -> k.getElementId().equals(menuId)).findFirst().get();
PairList<String,String> events = getEvents();
for(Pair<String, String> event : events ) {
MHandledMenuItem menuItem = modelService.createModelElement(MHandledMenuItem.class);
MParameter parameter = modelService.createModelElement(MParameter.class);
menuItem.setLabel(event.getLeft());
menuItem.setCommand(command);
parameter.setName(ApplicationContants.MParameter_General_Sendbroker);
parameter.setValue(event.getRight());
menuItem.getParameters().add(parameter);
menu.getChildren().add(menuItem);
}
}
private PairList<String,String> getEvents(){
PairList<String,String> pairlist = new PairList<>();
Field[] fields = FrameworkConstants.class.getFields();
for(Field f : fields) {
try {
String name = f.getName();
String value = (String)f.get(null);
name = name.replaceAll("TOPIC_", "");
pairlist.put(name, value);
// System.out.println(name + " -> " + value );
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
return pairlist;
}
}
@@ -0,0 +1,14 @@
package flintstones.application.debug.handler;
import org.eclipse.e4.core.di.annotations.Execute;
import flintstones.helper.data.text.DebugStream;
@SuppressWarnings("javadoc")
public class SystemOutDebugHandler {
@Execute
private void execute() {
DebugStream.activate();
}
}