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
+7
View File
@@ -0,0 +1,7 @@
<?flintstones.helper.data.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.operator</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] flintstones.operator</name>
<organization>
<name>Sinbad2</name>
</organization>
</project>
+50
View File
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.operator</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>1779484362731</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,29 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: flintstones.operator
Bundle-SymbolicName: flintstones.operator;singleton:=true
Bundle-Vendor: Sinbad2
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: flintstones.entity.valuation,
flintstones.model.valuation.service,
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di,
flintstones.helper.extensionpoint,
org.eclipse.e4.ui.model.workbench,
flintstones.entity.wvaluation,
flintstones.entity.extensionenum,
org.eclipse.e4.ui.services,
org.eclipse.swt,
javax.inject,
flintstones.model.ui.service,
flintstones.entity.operator,
flintstones.domain.fuzzyset
Export-Package: flintstones.operator.provider,
flintstones.operator.service
Automatic-Module-Name: flintstones.aggregationoperator
Service-Component: component.xml
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.jface.dialogs,
org.eclipse.jface.wizard,
org.eclipse.swt
Bundle-Version: 1.0.0.qualifier
@@ -0,0 +1,6 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
component.xml,\
plugin.xml
source.. = src/
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="operator context function">
<implementation class="flintstones.operator.provider.OperatorServiceContextFunction" />
<property name="service.context.key" type="String" value="flintstones.operator.service.IOperatorService" />
<service>
<provide interface="org.eclipse.e4.core.contexts.IContextFunction" />
</service>
</scr:component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="flintstones.operator.aggregation.extensionpoint" name="Aggregation Operator extension point" schema="schema/aggregation.operator.exsd"/>
<extension-point id="flintstones.operator.normalization" name="Normalization Operator extension point" schema="schema/normalization.operator.exsd"/>
</plugin>
@@ -0,0 +1,145 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="flintstones.aggregationoperator" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="flintstones.aggregationoperator" id="flintstones.operator.aggregation.extensionpoint" name="Aggregation operator"/>
</appinfo>
<documentation>
Este punto de extensión permite añadir nuevos operadores de agregación. Cada operador de agregación definido (aggregation_operator_type) podrá ser implementado para las distintas &quot;valuation&quot;, para eso se agregarán al mismo aggregation_operator.
Por ejemplo podremos añadir el aggregation_operator_type Max e implementarlo para el evaluaciones numéricas enteras y para evaluaciones de tipo lingüístico fuzzyset.
==============================================================================================================================================
This extension point allows you to add new aggregation operators. Each defined aggregation_operator_type can be implemented for the different valuation, for that they will be added to the same aggregation_operator.
For example, we can add the aggregation_operator_type Max and implement it for entire numerical evaluations and for fuzzyset linguistic evaluations.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="aggregation_operator_type"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="xid" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="aggregation_operator_type">
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="aggregation_operator"/>
</choice>
<attribute name="uid" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="implementation" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="flintstones.operator.aggregation.AggregationOperator:"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="aggregation_operator">
<complexType>
<attribute name="implementation" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="flintstones.operator.aggregation.AggregationOperator:"/>
</appinfo>
</annotation>
</attribute>
<attribute name="valuationId" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="flintstones.valuation/valuation/@uid"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
@@ -0,0 +1,127 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="flintstones.operator" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="flintstones.operator" id="flintstones.operator.normalization.extensionpoint" name="[EXP] Normalization Operator"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice>
<element ref="normalization_operator"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="xid" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="normalization_operator">
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="matching_valuation"/>
</choice>
<attribute name="implementation" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="flintstones.entity.operator.NormalizationOperator:"/>
</appinfo>
</annotation>
</attribute>
<attribute name="uid" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="matching_valuation">
<complexType>
<attribute name="valuationId" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="flintstones.valuation/valuation/@uid"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
@@ -0,0 +1,19 @@
package flintstones.operator.exception;
/**
* The Class AggregationOperatorNotFound.
*/
public class AggregationOperatorNotFound extends Error {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 3486693795198966709L;
/**
* Instantiates a new aggregation operator not found.
*
* @param operatorId the operator id
*/
public AggregationOperatorNotFound(String operatorId) {
super("El operador con ID " + operatorId + " no se ha encontrado"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -0,0 +1,20 @@
package flintstones.operator.exception;
/**
* The Class AggregationOperatorNotImplementedForValuation.
*/
public class AggregationOperatorNotImplementedForValuation extends Exception {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 8029363988701450857L;
/**
* Instantiates a new aggregation operator not implemented for valuation.
*
* @param operatorId the operator id
* @param valuationId the valuation id
*/
public AggregationOperatorNotImplementedForValuation(String operatorId, String valuationId) {
super("El operador con ID " + operatorId + " no tiene implementación para la evaluación " + valuationId + "." ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -0,0 +1,13 @@
package flintstones.operator.exception;
public class NormalizationOperatorIncompatible extends Error {
/**
*
*/
private static final long serialVersionUID = 273710095661069675L;
public NormalizationOperatorIncompatible(String operatorId, String valuationId){
super("El operador con id " + operatorId + " no puede normalizar operaciones del tipo " + valuationId );
}
}
@@ -0,0 +1,28 @@
package flintstones.operator.provider;
import org.eclipse.e4.core.contexts.ContextFunction;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.MApplication;
import flintstones.operator.service.IOperatorService;
/**
* The Class DomainServiceContextFunction add the Domain Service instance to global context.
*/
public class OperatorServiceContextFunction extends ContextFunction {
/* (non-Javadoc)
*
* @see
* org.eclipse.e4.core.contexts.ContextFunction#compute(org.eclipse.e4.core.
* contexts.IEclipseContext, java.lang.String) */
@Override
public Object compute(IEclipseContext context, String contextKey) {
IOperatorService service = ContextInjectionFactory.make(OperatorServiceProvider.class, context);
MApplication application = context.get(MApplication.class);
IEclipseContext applicationContext = application.getContext();
applicationContext.set(IOperatorService.class, service);
return service;
}
}
@@ -0,0 +1,204 @@
package flintstones.operator.provider;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.entity.operator.AggregationOperator;
import flintstones.entity.operator.NormalizationOperator;
import flintstones.entity.operator.interfaces.IUnweightedAggregationOperator;
import flintstones.entity.operator.interfaces.IWeightedAggregationOperator;
import flintstones.entity.valuation.Valuation;
import flintstones.entity.wvaluation.WValuation;
import flintstones.helper.extensionpoint.BaseRegistry;
import flintstones.helper.extensionpoint.ExtensionRegistry;
import flintstones.operator.exception.AggregationOperatorNotFound;
import flintstones.operator.exception.AggregationOperatorNotImplementedForValuation;
import flintstones.operator.exception.NormalizationOperatorIncompatible;
import flintstones.operator.service.IOperatorService;
/**
* The Class AggregationOperatorServiceProvider.
*
* @author Sinbad2
* AggregationOperator Service.
*/
public class OperatorServiceProvider implements IOperatorService {
/** The extension point. */
private final String EXTENSION_POINT_AGGREGATION = "flintstones.operator.aggregation.extensionpoint"; //$NON-NLS-1$
private final String EXTENSION_POINT_NORMALIZATION = "flintstones.operator.normalization"; //$NON-NLS-1$
/** The context. */
@Inject
IEclipseContext context;
/** The register. */
private final BaseRegistry aggregationReg;
private final BaseRegistry normalizationReg;
/**
* Instantiates a new aggregation operator service provider.
*/
public OperatorServiceProvider() {
this.aggregationReg = new BaseRegistry(this.EXTENSION_POINT_AGGREGATION);
this.normalizationReg = new BaseRegistry(this.EXTENSION_POINT_NORMALIZATION);
}
/* (non-Javadoc)
*
* @see flintstones.operator.aggregation.service.IAggregationOperatorService#
* getAggregationOperator(java.lang.String) */
@Override
public AggregationOperator getAggregationOperator(String operatorId, String valuationId) {
// The ER of the operator_type, allow us to find in its children the right
// implementation for the given valuations
ExtensionRegistry typeEr = aggregationReg.getFirstRegistryWhere(AggregationOperator.Fields.uid, operatorId);
if(typeEr == null)
throw new AggregationOperatorNotFound(operatorId);
// We need the registry of the aggregation_operator to instance it
ExtensionRegistry selectedOperator = null;
for (ExtensionRegistry local : typeEr.getAttributeReferences(AggregationOperator.Fields.aggregation_operator)) {
if (local.getAttribute(AggregationOperator.Fields.valuationId).equals(valuationId)) {
selectedOperator = local;
break;
}
}
if(selectedOperator == null ) {
try {
throw new AggregationOperatorNotImplementedForValuation(operatorId, valuationId);
} catch(AggregationOperatorNotImplementedForValuation e) {
System.err.println(e.getMessage());
}
return null;
}
AggregationOperator operator = (AggregationOperator) aggregationReg.instantiate(selectedOperator, context);
operator.setId(operatorId);
return operator;
}
/*@SuppressWarnings("unchecked")
@Override
public Valuation aggregate(String operatorId, List<Valuation> valuations, List<?> weights) {
String valuationId = valuations.get(0).getId();
AggregationOperator operator = this.getAggregationOperator(operatorId, valuationId);
Valuation result;
if ((operator instanceof IWeightedAggregationOperator ||
operator instanceof IFuzzyWeightedAggregationOperator)
&& weights != null)
if(weights.get(0) instanceof Double)
result = ((IWeightedAggregationOperator) operator).aggregate(valuations, (List<Double>) weights);
else
result = ((IFuzzyWeightedAggregationOperator) operator).aggregateF(valuations, (List<TrapezoidalFunction>) weights);
else
result = ((IUnweightedAggregationOperator) operator).aggregate(valuations);
result.setId(valuationId);
return result;
}*/
/*@Override
public Valuation aggregate(String operatorId, List<Valuation> valuations) {
return this.aggregate(operatorId, valuations, null);
}*/
@Override
public AggregationOperator[] getAggregationOperatorsFor(String valuationId, boolean importedWeights) {
ArrayList<AggregationOperator> operators = new ArrayList<>();
String[] operatorIds = aggregationReg.getAllAttributes(AggregationOperator.Fields.uid);
for (String operatorId : operatorIds) {
AggregationOperator operator = getAggregationOperator(operatorId, valuationId);
if (operator != null) {
if((operator instanceof IUnweightedAggregationOperator) ||
(operator instanceof IWeightedAggregationOperator && importedWeights))
operators.add(operator);
}
}
return operators.toArray(new AggregationOperator[operators.size()]);
}
@Override
public NormalizationOperator getNormalizationOperator(String operatorId) {
NormalizationOperator op = (NormalizationOperator) this.normalizationReg.instantiate(operatorId, context);
op.setId(operatorId);
return op;
}
@Override
public NormalizationOperator[] getNormalizationOperatorsFor(Valuation v) {
String valuationId = v.getId();
ArrayList<NormalizationOperator> operators = new ArrayList<>();
for( ExtensionRegistry er : normalizationReg.getAllRegistries() ) {
ExtensionRegistry matchingValuationsEr[] = er.getAttributeReferences("matching_valuation");
for(ExtensionRegistry matchingValuation : matchingValuationsEr) {
if( matchingValuation.getAttribute("valuationId").equals(valuationId)) {
NormalizationOperator op = this.getNormalizationOperator(er.getAttribute("uid"));
operators.add(op);
continue;
}
}
}
return operators.toArray(new NormalizationOperator[operators.size()]);
}
@Override
public WValuation[] normalize(String operatorId, List<WValuation> valuations) {
return this.normalize(operatorId, valuations, null);
}
@Override
public WValuation[] normalize(String operatorId, List<WValuation> valuations, List<Double> weights) {
if(weights != null)
throw new RuntimeException("No es posible normalizar con pesos.");
ExtensionRegistry er = this.normalizationReg.getFirstRegistryWhere("uid",operatorId);
String valuationId = valuations.get(0).getValuation().getId();
if(!isMatchingValuation(er, valuationId)) {
throw new NormalizationOperatorIncompatible(operatorId, valuationId);
}
NormalizationOperator op = this.getNormalizationOperator(er.getAttribute("uid"));
WValuation[] result = op.normalize(valuations);
return result;
}
private boolean isMatchingValuation(ExtensionRegistry normalizationOperatorRegistry, String valuationId) {
ExtensionRegistry[] valuationRegistries = normalizationOperatorRegistry.getAttributeReferences("matching_valuation");
for(ExtensionRegistry ex : valuationRegistries) {
if( ex.getAttribute("valuationId").equals(valuationId) ) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,56 @@
package flintstones.operator.service;
import java.util.List;
import flintstones.entity.operator.AggregationOperator;
import flintstones.entity.operator.NormalizationOperator;
import flintstones.entity.valuation.Valuation;
import flintstones.entity.wvaluation.WValuation;
/**
* The Interface IAggregationOperatorService.
*/
public interface IOperatorService {
/**
* Gets a aggregation operator by its id.
*
* @param operatorId the operator id
* @param valuationId the valuation id
* @return Instanced AggregationOperator
*/
AggregationOperator getAggregationOperator(String operatorId, String valuationId);
/**
* Aggregate.
*
* @param operatorId the operator id
* @param valuations the valuations
* @return Final valuation
*/
//Valuation aggregate(String operatorId, List<Valuation> valuations);
/**
* Aggregate.
*
* @param operatorId the operator id
* @param valuations the valuations
* @param weights the weights
* @return Final valuation
*/
//Valuation aggregate(String operatorId, List<Valuation> valuations, List<?> weights);
AggregationOperator[] getAggregationOperatorsFor(String valuationId, boolean weights);
// NORMALIZATION
WValuation[] normalize(String operatorId, List<WValuation> valuations);
WValuation[] normalize(String operatorId, List<WValuation> valuations, List<Double> weights);
NormalizationOperator getNormalizationOperator(String operatorId);
NormalizationOperator[] getNormalizationOperatorsFor(Valuation v);
}