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,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.unification</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Unification operator</name>
<organization>
<name>Sinbad2</name>
</organization>
</project>
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.operator.unification</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>1779484362737</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,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Unification operator
Bundle-SymbolicName: flintstones.operator.unification;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Sinbad2
Automatic-Module-Name: flintstones.operator.unification
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: flintstones.entity.valuation;visibility:=reexport,
flintstones.helper.extensionpoint,
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di,
org.eclipse.e4.ui.model.workbench,
javax.inject
Service-Component: component.xml
Bundle-ActivationPolicy: lazy
Export-Package: flintstones.operator.unification,
flintstones.operator.unification.service
@@ -0,0 +1,6 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
component.xml,\
plugin.xml
source.. = src/
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="unification operator context function">
<implementation class="flintstones.operator.unification.provider.UnificationOperatorServiceContextFunction"/>
<property name="service.context.key" type="String" value="flintstones.operator.unification.service.IUnificationOperatorService"/>
<service>
<provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
</service>
</scr:component>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="flintstones.operator.unification.extensionpoint" name="Unification operator extension point" schema="schema/flintstones.operator.unification.extensionpoint.exsd"/>
</plugin>
@@ -0,0 +1,140 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="flintstones.operator.unification" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="flintstones.operator.unification" id="flintstones.operator.unification.extensionpoint" name="Unification operator extension point"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice>
<element ref="final_valuation"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" 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="final_valuation">
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="source_valuation"/>
</choice>
<attribute name="final_valuation_type" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="flintstones.valuation/valuation/@uid"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="source_valuation">
<complexType>
<attribute name="source_valuation_type" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="flintstones.valuation/valuation/@uid"/>
</appinfo>
</annotation>
</attribute>
<attribute name="specific_method" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="flintstones.method.extension/method/@uid"/>
</appinfo>
</annotation>
</attribute>
<attribute name="implementation" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="flintstones.operator.unification.UnificationOperator:"/>
</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,130 @@
package flintstones.operator.unification;
import flintstones.entity.domain.Domain;
import flintstones.entity.extensionenum.ExtensionEnum;
import flintstones.entity.valuation.Valuation;
public abstract class UnificationOperator {
/** The id. */
protected String id;
/** The name. */
protected String name;
/** The source valuation id. */
protected String source_valuation_id;
/** The final valuation id. */
protected String final_valuation_id;
/**
* The Class Fields.
*/
public enum Fields implements ExtensionEnum {
/** The id. */
id,
/** The name. */
name,
/** The implementation. */
implementation,
/** The source valuation. */
source_valuation,
/** The final valuation. */
final_valuation,
/** The source valuation id. */
source_valuation_type,
/** The final valuation id. */
final_valuation_type,
/** The specific method id. */
specific_method;
}
/**
* Instantiates a new aggregation operator.
*/
public UnificationOperator() {
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return this.id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(String id) {
this.id = id;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return this.name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the source valuation id.
*
* @return the source valuation id
*/
public String getSourceValuationId() {
return this.source_valuation_id;
}
/**
* Sets the source valuation id.
*
* @param name the new source valuation id
*/
public void setSourceValuationId(String source_valuation_id) {
this.source_valuation_id = source_valuation_id;
}
/**
* Gets the final valuation id.
*
* @return the final valuation id
*/
public String getFinalValuationId() {
return this.final_valuation_id;
}
/**
* Sets the final valuation id.
*
* @param name the new final valuation id
*/
public void setFinalValuationId(String final_valuation_id) {
this.final_valuation_id = final_valuation_id;
}
/**
* Unify valuation
* @param valuation valuation to unify
* @param unificationDomain unification domain
* @return unified valuation
*/
public abstract Valuation unify(Domain unificationDomain, Valuation valuation);
}
@@ -0,0 +1,19 @@
package flintstones.operator.unification.exception;
/**
* The Class AggregationOperatorNotFound.
*/
public class UnificationOperatorFinalValuationNotFound extends Error {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 3486693795198966709L;
/**
* Instantiates a new unification operator not found.
*
* @param operatorId the operator id
*/
public UnificationOperatorFinalValuationNotFound(String finalValuation) {
super("No existe operador de unificación que pueda unificar a " + finalValuation); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -0,0 +1,20 @@
package flintstones.operator.unification.exception;
/**
* The Class AggregationOperatorNotImplementedForValuation.
*/
public class UnificationOperatorNotImplemented 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 UnificationOperatorNotImplemented(String sourceValuation, String finalValuation) {
super("No existe operador de unificación que unifique la valoración " + sourceValuation + " a la valoración " + finalValuation + "." ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@@ -0,0 +1,26 @@
package flintstones.operator.unification.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.unification.service.IUnificationOperatorService;
public class UnificationOperatorServiceContextFunction 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) {
IUnificationOperatorService service = ContextInjectionFactory.make(UnificationOperatorServiceProvider.class, context);
MApplication application = context.get(MApplication.class);
IEclipseContext applicationContext = application.getContext();
applicationContext.set(IUnificationOperatorService.class, service);
return service;
}
}
@@ -0,0 +1,115 @@
package flintstones.operator.unification.provider;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import flintstones.entity.domain.Domain;
import flintstones.entity.valuation.Valuation;
import flintstones.helper.extensionpoint.BaseRegistry;
import flintstones.helper.extensionpoint.ExtensionRegistry;
import flintstones.operator.unification.UnificationOperator;
import flintstones.operator.unification.exception.UnificationOperatorFinalValuationNotFound;
import flintstones.operator.unification.exception.UnificationOperatorNotImplemented;
import flintstones.operator.unification.service.IUnificationOperatorService;
public class UnificationOperatorServiceProvider implements IUnificationOperatorService {
/** The extension point. */
private final String EXTENSION_POINT_UNIFICATION = "flintstones.operator.unification.extensionpoint"; //$NON-NLS-1$
/** The context. */
@Inject
IEclipseContext context;
/** The register. */
private final BaseRegistry unificationReg;
/**
* Instantiates a new unification operator service provider.
*/
public UnificationOperatorServiceProvider() {
this.unificationReg = new BaseRegistry(this.EXTENSION_POINT_UNIFICATION);
}
/*
* (non-Javadoc)
*
* @see flintstones.operator.unification.service.IUnificationOperatorService#
* getAggregationOperator(java.lang.String)
*/
@Override
public UnificationOperator getUnificationOperator(String sourceValuation, String finalValuation, String methodId) {
// The ER of the operator_type, allow us to find in its children the right
// implementation for the given valuations
ExtensionRegistry[] registries = unificationReg.getAllRegistriesWhere("final_valuation_type", finalValuation);
if (registries.length == 0)
throw new UnificationOperatorFinalValuationNotFound(finalValuation);
// We need the registry of the unification operator to instance it
ExtensionRegistry selectedOperator = getUnificationOperator(registries, sourceValuation, finalValuation, methodId);
if (selectedOperator == null) {
try {
throw new UnificationOperatorNotImplemented(sourceValuation, finalValuation);
} catch (UnificationOperatorNotImplemented e) {
System.err.println(e.getMessage());
}
return null;
}
UnificationOperator operator = (UnificationOperator) unificationReg.instantiate(selectedOperator, context);
operator.setId(selectedOperator.getAttribute(UnificationOperator.Fields.id));
operator.setSourceValuationId(sourceValuation);
operator.setFinalValuationId(finalValuation);
return operator;
}
private ExtensionRegistry getUnificationOperator(ExtensionRegistry[] registries, String sourceValuation, String finalValuation, String methodId) {
List<ExtensionRegistry> registriesByValuation = new ArrayList<>();
ExtensionRegistry selectedOperator = null;
//Get unification operators with the same source and final valuation
for(ExtensionRegistry local: registries) {
for(ExtensionRegistry sourceRegistry: local.getAttributeReferences(UnificationOperator.Fields.source_valuation)) {
if(sourceRegistry.getAttribute(UnificationOperator.Fields.source_valuation_type).equals(sourceValuation))
registriesByValuation.add(sourceRegistry);
}
}
//Get the unification operator for a specific method if necessary
if(registriesByValuation.size() == 1)
selectedOperator = registriesByValuation.get(0);//Default unification operator
else {
String methodIdAttribute;
for(ExtensionRegistry local: registriesByValuation) {
methodIdAttribute = local.getAttribute(UnificationOperator.Fields.specific_method);
if(methodIdAttribute != null) {
if(methodIdAttribute.equals(methodId))
selectedOperator = local;//Unification operator for specific domain
} else
selectedOperator = local;//Default unification operator
}
}
return selectedOperator;
}
@Override
public Valuation unify(Domain unificationDomain, Valuation valuation, String finalValuationType, String methodId) {
UnificationOperator operator = this.getUnificationOperator(valuation.getId(), finalValuationType, methodId);
Valuation result = operator.unify(unificationDomain, valuation);
result.setId(finalValuationType);
return result;
}
}
@@ -0,0 +1,33 @@
package flintstones.operator.unification.service;
import flintstones.entity.domain.Domain;
import flintstones.entity.valuation.Valuation;
import flintstones.operator.unification.UnificationOperator;
/**
* The Interface IUnificationOperatorService.
*/
public interface IUnificationOperatorService {
/**
* Gets an unification operator for a specific method by the type of the source valuation and the type of the unified valuation.
*
* @param sourceValuationId id of source valuation
* @param finalValuationId id of valuation to unify
* @param methodId id of the method
* @return Instanced UnificationOperator
*/
UnificationOperator getUnificationOperator(String sourceValuationId, String finalValuationId, String methodId);
/**
* Unify.
*
* @param unificationDomain unification domain
* @param valuation valuation to unify
* @param finalValuationId id of valuation to unify
* @param methodId id of the method
* @return Final unified valuation
*/
Valuation unify(Domain unificationDomain, Valuation valuation, String finalValuationId, String methodId);
}