Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added REXS 2.0.0
- Added equivalent untis to `RexsStandardUnitIds` (`deg`, `degree`)
- Changelog: Added changes to allowed combinations in relations.

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/info/rexs/schema/RexsSchemaFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class RexsSchemaFile {
/** REXS 1.7 */
public static final RexsSchemaFile V1_7 = create(RexsStandardVersions.V1_7);

/** REXS 2.0.0 */
public static final RexsSchemaFile V2_0_0 = create(RexsStandardVersions.V2_0_0);

/** The {@link RexsVersion} of the REXS schema file. */
private final RexsVersion version;

Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/info/rexs/schema/RexsSchemaRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private RexsSchemaRegistry() {
registerRexsVersion(RexsStandardVersions.V1_5);
registerRexsVersion(RexsStandardVersions.V1_6);
registerRexsVersion(RexsStandardVersions.V1_7);
registerRexsVersion(RexsStandardVersions.V2_0_0);
} catch (Exception ex) {
throw new RuntimeException("error while registering rexs model:", ex);
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/info/rexs/schema/constants/RexsVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public static RexsVersion create(String schemaVersion, String schemaProvider, St
}

// assure that the schema version follows X.X pattern
if (!schemaVersion.matches("\\d+\\.\\d+") && !schemaVersion.equalsIgnoreCase(DEV_VERSION_NAME))
throw new IllegalArgumentException("schemaVersion must follow the pattern X.X");
if (!schemaVersion.matches("\\d+\\.\\d+(\\.\\d)?") && !schemaVersion.equalsIgnoreCase(DEV_VERSION_NAME))
throw new IllegalArgumentException("schemaVersion must follow the pattern X.X or X.X.X");

// create the primary version
RexsVersion primaryVersion = new RexsVersion(schemaVersion, schemaProvider, primaryModelVersion, List.of(additionalModelVersions));
Expand Down
4,266 changes: 2,823 additions & 1,443 deletions api/src/main/java/info/rexs/schema/constants/standard/RexsStandardAttributeIds.java

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,71 @@
/**
* This class represents a REXS relation role.
* <p>
* It contains constants for all relation roles of official REXS versions (1.3, 1.4, 1.5, 1.6, 1.7).
* It contains constants for all relation roles of official REXS versions (1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0).
*
* @author FVA GmbH
*/
@Generated("REXS-Database by FVA GmbH (see https://database.rexs.info/)")
public interface RexsStandardRelationRoles {

/** Relation role "assembly" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "assembly" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole assembly = RexsRelationRole.create("assembly");

/** Relation role "gear" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "gear" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole gear = RexsRelationRole.create("gear");

/** Relation role "gear_1" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "gear_1" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole gear_1 = RexsRelationRole.create("gear_1");

/** Relation role "gear_2" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "gear_2" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole gear_2 = RexsRelationRole.create("gear_2");

/** Relation role "inner_part" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "inner_part" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole inner_part = RexsRelationRole.create("inner_part");

/** Relation role "left" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "left" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole left = RexsRelationRole.create("left");

/** Relation role "manufacturing_settings" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "manufacturing_settings" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole manufacturing_settings = RexsRelationRole.create("manufacturing_settings");

/** Relation role "origin" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "origin" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole origin = RexsRelationRole.create("origin");

/** Relation role "outer_part" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "outer_part" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole outer_part = RexsRelationRole.create("outer_part");

/** Relation role "part" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "part" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole part = RexsRelationRole.create("part");

/** Relation role "planetary_stage" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "planetary_stage" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole planetary_stage = RexsRelationRole.create("planetary_stage");

/** Relation role "referenced" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "referenced" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole referenced = RexsRelationRole.create("referenced");

/** Relation role "right" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "right" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole right = RexsRelationRole.create("right");

/** Relation role "shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole shaft = RexsRelationRole.create("shaft");

/** Relation role "side_1" (Versions: 1.6, 1.7). */
/** Relation role "side_1" (Versions: 1.6, 1.7, 2.0.0). */
RexsRelationRole side_1 = RexsRelationRole.create("side_1");

/** Relation role "side_2" (Versions: 1.6, 1.7). */
/** Relation role "side_2" (Versions: 1.6, 1.7, 2.0.0). */
RexsRelationRole side_2 = RexsRelationRole.create("side_2");

/** Relation role "stage" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "stage" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole stage = RexsRelationRole.create("stage");

/** Relation role "stage_gear_data" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "stage_gear_data" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole stage_gear_data = RexsRelationRole.create("stage_gear_data");

/** Relation role "tool" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "tool" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole tool = RexsRelationRole.create("tool");

/** Relation role "workpiece" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation role "workpiece" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationRole workpiece = RexsRelationRole.create("workpiece");

/** Constant for an unknown relation role. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,43 @@
@Generated("REXS-Database by FVA GmbH (see https://database.rexs.info/)")
public interface RexsStandardRelationTypes {

/** Relation type "assembly" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "assembly" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType assembly = RexsRelationType.create("assembly", RexsStandardRelationRoles.assembly, RexsStandardRelationRoles.part);

/** Relation type "central_shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "central_shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType central_shaft = RexsRelationType.create("central_shaft", RexsStandardRelationRoles.planetary_stage, RexsStandardRelationRoles.shaft);

/** Relation type "contact" (Versions: 1.6, 1.7). */
/** Relation type "contact" (Versions: 1.6, 1.7, 2.0.0). */
RexsRelationType contact = RexsRelationType.create("contact", RexsStandardRelationRoles.assembly, RexsStandardRelationRoles.side_1, RexsStandardRelationRoles.side_2);

/** Relation type "flank" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "flank" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType flank = RexsRelationType.create("flank", RexsStandardRelationRoles.gear, RexsStandardRelationRoles.left, RexsStandardRelationRoles.right);

/** Relation type "manufacturing_step" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "manufacturing_step" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType manufacturing_step = RexsRelationType.create("manufacturing_step", RexsStandardRelationRoles.manufacturing_settings, RexsStandardRelationRoles.tool, RexsStandardRelationRoles.workpiece);

/** Relation type "ordered_assembly" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "ordered_assembly" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType ordered_assembly = RexsRelationType.create("ordered_assembly", RexsStandardRelationRoles.assembly, RexsStandardRelationRoles.part);

/** Relation type "planet_carrier_shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "planet_carrier_shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType planet_carrier_shaft = RexsRelationType.create("planet_carrier_shaft", RexsStandardRelationRoles.planetary_stage, RexsStandardRelationRoles.shaft);

/** Relation type "planet_pin" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "planet_pin" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType planet_pin = RexsRelationType.create("planet_pin", RexsStandardRelationRoles.planetary_stage, RexsStandardRelationRoles.shaft);

/** Relation type "planet_shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "planet_shaft" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType planet_shaft = RexsRelationType.create("planet_shaft", RexsStandardRelationRoles.planetary_stage, RexsStandardRelationRoles.shaft);

/** Relation type "reference" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "reference" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType reference = RexsRelationType.create("reference", RexsStandardRelationRoles.origin, RexsStandardRelationRoles.referenced);

/** Relation type "side" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "side" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType side = RexsRelationType.create("side", RexsStandardRelationRoles.assembly, RexsStandardRelationRoles.inner_part, RexsStandardRelationRoles.outer_part);

/** Relation type "stage" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "stage" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType stage = RexsRelationType.create("stage", RexsStandardRelationRoles.gear_1, RexsStandardRelationRoles.gear_2, RexsStandardRelationRoles.stage);

/** Relation type "stage_gear_data" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7). */
/** Relation type "stage_gear_data" (Versions: 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0). */
RexsRelationType stage_gear_data = RexsRelationType.create("stage_gear_data", RexsStandardRelationRoles.gear, RexsStandardRelationRoles.stage, RexsStandardRelationRoles.stage_gear_data);

/** Constant for an unknown relation type. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* This class represents a REXS unit.
* <p>
* It contains constants for all units of official REXS versions (1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7).
* It contains constants for all units of official REXS versions (1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 2.0.0).
*
* @author FVA GmbH
*/
Expand Down Expand Up @@ -210,6 +210,21 @@ public interface RexsStandardUnitIds {
/** kg / mm */
RexsUnitId unit_61 = RexsUnitId.create("kg / mm", 61);

/** pF */
RexsUnitId unit_62 = RexsUnitId.create("pF", 62);

/** Ohm */
RexsUnitId unit_63 = RexsUnitId.create("Ohm", 63);

/** V */
RexsUnitId unit_64 = RexsUnitId.create("V", 64);

/** pS / m */
RexsUnitId unit_65 = RexsUnitId.create("pS / m", 65);

/** V / m */
RexsUnitId unit_66 = RexsUnitId.create("V / m", 66);

/** W */
RexsUnitId watt = RexsUnitId.create("W", 29);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ public final class RexsStandardVersions {
*/
public static final RexsVersion V1_7 = RexsVersion.create("1.7", null, "1.7");

/**
* Version 2.0.0 of the REXS schema.
*/
public static final RexsVersion V2_0_0 = RexsVersion.create("2.0.0", null, "2.0.0");

/**
* @return
* The latest official REXS {@link RexsVersion}.
*/
public static RexsVersion getLatest() {
return V1_7;
return V2_0_0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,22 @@ private void editAttributesById(String attributeId, List<ChangedValue> changedVa
break;
}
case "unit": {
if (changedValue.getOldValue().equals("\u00B0") && changedValue.getNewValue().equals("deg")) {
attribute.setUnit(RexsStandardUnitIds.deg);
} else
if (changedValue.getOldValue().equals("N") && changedValue.getNewValue().equals("N / mm")) {
RexsUnitId oldUnit = RexsUnitId.findById(changedValue.getOldValue());
RexsUnitId newUnit = RexsUnitId.findById(changedValue.getNewValue());

if (oldUnit.isEquivalent(newUnit)) {
attribute.setUnit(newUnit);

} else if (oldUnit.equals(RexsStandardUnitIds.newton) && newUnit.equals(RexsStandardUnitIds.newton_per_mm)) {
attribute.setUnit(RexsStandardUnitIds.newton_per_mm);
notifications.add(new Notification(NotificationType.WARNING, "unit conversion from N to N/mm",
new AttributeSource(attribute.getAttributeId().getId())));

} else {
throw new RuntimeException("unsupported unit conversion");
throw new RuntimeException(
String.format("unsupported unit conversion from %s to %s", changedValue.getOldValue(), changedValue.getNewValue()));
}
RexsUnitId unit = RexsUnitId.findById(changedValue.getNewValue());
attribute.setUnit(unit);

break;
}
case "symbol": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package info.rexs.upgrade.upgraders;

import info.rexs.schema.constants.standard.RexsStandardVersions;
import info.rexs.model.RexsModel;
import info.rexs.upgrade.RexsUpgradeException;
import info.rexs.upgrade.upgraders.changelog.ChangelogFile;
import info.rexs.upgrade.upgraders.changelog.ChangelogResolver;
import info.rexs.upgrade.upgraders.changelog.jaxb.RexsChangelog;

public class ModelUpgraderV17toV20 {

private static final ChangelogFile CHANGELOG_FILE = ChangelogFile.V1_7_TO_V2_0_0;

private RexsModel newModel;
private final RexsModel oldModel;
private final boolean strictMode;

private RexsChangelog changelog;
private UpgradeNotifications notifications = new UpgradeNotifications();

public ModelUpgraderV17toV20(RexsModel model, boolean strictMode) {
this.oldModel = model;
this.newModel = new RexsModel(model);
this.strictMode = strictMode;

try {
this.changelog = ChangelogResolver.getInstance().resolve(CHANGELOG_FILE);
} catch(RexsUpgradeException ex) {
System.err.println(ex);
}
}

public ModelUpgraderResult doupgrade() throws RexsUpgradeException {
ModelChangelogUpgrader changeLogUpgrader = new ModelChangelogUpgrader(newModel, changelog, strictMode);
newModel = changeLogUpgrader.applyChangelog();
notifications.addAll(changeLogUpgrader.getNotifications().getNotifications());

newModel.setVersion(RexsStandardVersions.V2_0_0);
newModel.setApplicationId("REXS API Upgrader");

return new ModelUpgraderResult(newModel, notifications);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public ModelUpgraderResult upgrade(RexsModel rexsModel, boolean strictMode) thro
return upgrader.doupgrade();
}
});

register(RexsStandardVersions.V1_7, RexsStandardVersions.V2_0_0, new ModelUpgrader() {
@Override
public ModelUpgraderResult upgrade(RexsModel rexsModel, boolean strictMode) throws RexsUpgradeException {
ModelUpgraderV17toV20 upgrader = new ModelUpgraderV17toV20(rexsModel, strictMode);
return upgrader.doupgrade();
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class ChangelogFile {
/** REXS Changelog 1.6 to 1.7 */
public static final ChangelogFile V1_6_TO_V1_7 = create(RexsStandardVersions.V1_6, RexsStandardVersions.V1_7);

/** REXS Changelog 1.7 to 2.0.0 */
public static final ChangelogFile V1_7_TO_V2_0_0 = create(RexsStandardVersions.V1_7, RexsStandardVersions.V2_0_0);

/** The from {@link RexsVersion} of the REXS database changelog file. */
private final RexsVersion fromVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;

import info.rexs.schema.RexsSchemaRegistry;
import info.rexs.schema.IRexsSchemaRegistry;
Expand Down Expand Up @@ -66,7 +66,7 @@ public RexsValidationResult validate(RexsAttribute rexsAttribute, RexsComponent
boolean attributeKnown = true;

if (!rexsSchemaRegistry.hasAttributeWithId(rexsVersion, attributeId)) {
if (StringUtils.startsWith(attributeId, "custom_"))
if (Strings.CS.startsWith(attributeId, "custom_"))
validationResult.addWarning(RexsValidationResultMessageKey.ATTRIBUTE_ID_CUSTOM, attributeId);
else
validationResult.addError(RexsValidationResultMessageKey.ATTRIBUTE_ID_UNKNOWN, attributeId);
Expand Down
Loading