Skip to content

Commit

Permalink
Merge branch 'release/2023-01-rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-gomes committed Feb 9, 2023
2 parents 85c6bb9 + 999a8b0 commit 2d322a2
Show file tree
Hide file tree
Showing 185 changed files with 742,721 additions and 760,910 deletions.
45 changes: 39 additions & 6 deletions app/dao/impl/jpa/JpaDataDao.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SysML v2 REST/HTTP Pilot Implementation
* Copyright (C) 2021-2022 Twingineer LLC
* Copyright (C) 2021-2023 Twingineer LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -20,6 +20,7 @@

package dao.impl.jpa;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Streams;
import config.MetamodelProvider;
import dao.DataDao;
Expand All @@ -40,6 +41,7 @@
import org.omg.sysml.lifecycle.impl.*;
import org.omg.sysml.query.*;
import org.omg.sysml.query.impl.QueryImpl;
import play.libs.Json;

import javax.inject.Inject;
import javax.persistence.EntityManager;
Expand All @@ -48,6 +50,7 @@
import javax.persistence.TypedQuery;
import javax.persistence.criteria.*;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
Expand Down Expand Up @@ -232,10 +235,23 @@ else if (constraint instanceof PrimitiveConstraint) {
return data -> {
Object actualValue;
Object constrainedValue;

JsonNode constrainedValueJson;
try {
constrainedValueJson = primitiveConstraint.getValue() != null ?
Json.mapper().readTree(primitiveConstraint.getValue()) :
null;
} catch (IOException e) {
throw new IllegalArgumentException(e);
}

switch (primitiveConstraint.getProperty()) {
case "@id":
actualValue = data.getId();
constrainedValue = JavaBeanHelper.convert(primitiveConstraint.getValue(), UUID.class);
constrainedValue = JavaBeanHelper.convert(
constrainedValueJson != null ? constrainedValueJson.asText() : null,
UUID.class
);
break;
case "@type":
try {
Expand All @@ -246,19 +262,36 @@ else if (constraint instanceof PrimitiveConstraint) {
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
constrainedValue = primitiveConstraint.getValue();
constrainedValue = constrainedValueJson != null ? constrainedValueJson.asText() : null;
break;
default:
PropertyDescriptor property = JavaBeanHelper.getBeanProperties(data).get(primitiveConstraint.getProperty());
if (property == null) {
return false;
}
if (SUPPORTED_PRIMITIVE_CONSTRAINT_CLASSES.stream()
.noneMatch(supported -> supported.isAssignableFrom(property.getPropertyType()))) {
.anyMatch(supported -> supported.isAssignableFrom(property.getPropertyType()))) {
actualValue = JavaBeanHelper.getBeanPropertyValue(data, property);
constrainedValue = JavaBeanHelper.convert(
constrainedValueJson != null ? constrainedValueJson.asText() : null,
property.getPropertyType()
);
} else if (Data.class.isAssignableFrom(property.getPropertyType())) {
Object _actualValue = JavaBeanHelper.getBeanPropertyValue(data, property);
actualValue = _actualValue != null ? ((Data) _actualValue).getId() : null;
constrainedValue = constrainedValueJson != null ?
JavaBeanHelper.convert(
// intentionally `textValue` instead of `asText` to get a null value for
// improved error reporting
constrainedValueJson.path("@id").textValue(),
UUID.class
) : null;
if (constrainedValue == null) {
throw new IllegalArgumentException();
}
} else {
return false;
}
actualValue = JavaBeanHelper.getBeanPropertyValue(data, property);
constrainedValue = JavaBeanHelper.convert(primitiveConstraint.getValue(), property.getPropertyType());
break;
}
if (actualValue == null || constrainedValue == null) {
Expand Down
22 changes: 21 additions & 1 deletion app/javabean/UuidPropertyEditor.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* SysML v2 REST/HTTP Pilot Implementation
* Copyright (C) 2022-2023 Twingineer LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*/

package javabean;

import java.beans.PropertyEditorSupport;
Expand All @@ -7,6 +27,6 @@ public class UuidPropertyEditor extends PropertyEditorSupport {

@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(UUID.fromString(text));
setValue(text != null ? UUID.fromString(text) : null);
}
}
1 change: 0 additions & 1 deletion app/org/omg/sysml/lifecycle/impl/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
@MetaValue(value = "PortConjugation", targetEntity = PortConjugationImpl.class),
@MetaValue(value = "PortDefinition", targetEntity = PortDefinitionImpl.class),
@MetaValue(value = "PortUsage", targetEntity = PortUsageImpl.class),
@MetaValue(value = "PortioningFeature", targetEntity = PortioningFeatureImpl.class),
@MetaValue(value = "Predicate", targetEntity = PredicateImpl.class),
@MetaValue(value = "Redefinition", targetEntity = RedefinitionImpl.class),
@MetaValue(value = "ReferenceSubsetting", targetEntity = ReferenceSubsettingImpl.class),
Expand Down
2 changes: 1 addition & 1 deletion app/org/omg/sysml/metamodel/FlowConnectionDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
import java.util.List;
import java.util.Set;

public interface FlowConnectionDefinition extends Interaction, ActionDefinition, ConnectionDefinition, SysMLType {
public interface FlowConnectionDefinition extends Interaction, ConnectionDefinition, ActionDefinition, SysMLType {

}
2 changes: 1 addition & 1 deletion app/org/omg/sysml/metamodel/MembershipExpose.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
import java.util.List;
import java.util.Set;

public interface MembershipExpose extends Expose, MembershipImport, SysMLType {
public interface MembershipExpose extends MembershipImport, Expose, SysMLType {

}
2 changes: 0 additions & 2 deletions app/org/omg/sysml/metamodel/OccurrenceUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
public interface OccurrenceUsage extends Usage, SysMLType {
List<? extends Class> getOccurrenceDefinition();

PortioningFeature getPortioningFeature();

OccurrenceDefinition getIndividualDefinition();

Boolean getIsIndividual();
Expand Down
31 changes: 0 additions & 31 deletions app/org/omg/sysml/metamodel/PortioningFeature.java

This file was deleted.

21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/AcceptActionUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2552,27 +2552,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "AcceptActionUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("qualifiedName")
private String qualifiedName;
Expand Down
21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/ActionUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2510,27 +2510,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "ActionUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("qualifiedName")
private String qualifiedName;
Expand Down
21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/AllocationUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2663,27 +2663,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "AllocationUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("qualifiedName")
private String qualifiedName;
Expand Down
21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/AnalysisCaseUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2685,27 +2685,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "AnalysisCaseUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("qualifiedName")
private String qualifiedName;
Expand Down
21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/AssertConstraintUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2581,27 +2581,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "AssertConstraintUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("predicate")
private Predicate predicate;
Expand Down
21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/AssignmentActionUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2510,27 +2510,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "AssignmentActionUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("qualifiedName")
private String qualifiedName;
Expand Down
21 changes: 0 additions & 21 deletions app/org/omg/sysml/metamodel/impl/CalculationUsageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2570,27 +2570,6 @@ public void setPortionKind(PortionKind portionKind) {



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("portioningFeature")
private PortioningFeature portioningFeature;

@JsonGetter
@JsonSerialize(using = DataSerializer.class)
// @javax.persistence.Transient
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
@JoinColumn(name = "portioningFeature_id", table = "CalculationUsage")
public PortioningFeature getPortioningFeature() {
return portioningFeature;
}

@JsonSetter
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
public void setPortioningFeature(PortioningFeature portioningFeature) {
this.portioningFeature = portioningFeature;
}



// @info.archinnov.achilles.annotations.Transient
// @info.archinnov.achilles.annotations.Column("qualifiedName")
private String qualifiedName;
Expand Down
Loading

0 comments on commit 2d322a2

Please sign in to comment.