Skip to content

Commit 2d322a2

Browse files
committed
Merge branch 'release/2023-01-rc1'
2 parents 85c6bb9 + 999a8b0 commit 2d322a2

185 files changed

Lines changed: 742721 additions & 760910 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/dao/impl/jpa/JpaDataDao.java

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* SysML v2 REST/HTTP Pilot Implementation
3-
* Copyright (C) 2021-2022 Twingineer LLC
3+
* Copyright (C) 2021-2023 Twingineer LLC
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -20,6 +20,7 @@
2020

2121
package dao.impl.jpa;
2222

23+
import com.fasterxml.jackson.databind.JsonNode;
2324
import com.google.common.collect.Streams;
2425
import config.MetamodelProvider;
2526
import dao.DataDao;
@@ -40,6 +41,7 @@
4041
import org.omg.sysml.lifecycle.impl.*;
4142
import org.omg.sysml.query.*;
4243
import org.omg.sysml.query.impl.QueryImpl;
44+
import play.libs.Json;
4345

4446
import javax.inject.Inject;
4547
import javax.persistence.EntityManager;
@@ -48,6 +50,7 @@
4850
import javax.persistence.TypedQuery;
4951
import javax.persistence.criteria.*;
5052
import java.beans.PropertyDescriptor;
53+
import java.io.IOException;
5154
import java.util.*;
5255
import java.util.concurrent.ConcurrentHashMap;
5356
import java.util.function.Function;
@@ -232,10 +235,23 @@ else if (constraint instanceof PrimitiveConstraint) {
232235
return data -> {
233236
Object actualValue;
234237
Object constrainedValue;
238+
239+
JsonNode constrainedValueJson;
240+
try {
241+
constrainedValueJson = primitiveConstraint.getValue() != null ?
242+
Json.mapper().readTree(primitiveConstraint.getValue()) :
243+
null;
244+
} catch (IOException e) {
245+
throw new IllegalArgumentException(e);
246+
}
247+
235248
switch (primitiveConstraint.getProperty()) {
236249
case "@id":
237250
actualValue = data.getId();
238-
constrainedValue = JavaBeanHelper.convert(primitiveConstraint.getValue(), UUID.class);
251+
constrainedValue = JavaBeanHelper.convert(
252+
constrainedValueJson != null ? constrainedValueJson.asText() : null,
253+
UUID.class
254+
);
239255
break;
240256
case "@type":
241257
try {
@@ -246,19 +262,36 @@ else if (constraint instanceof PrimitiveConstraint) {
246262
} catch (ClassNotFoundException e) {
247263
throw new IllegalStateException(e);
248264
}
249-
constrainedValue = primitiveConstraint.getValue();
265+
constrainedValue = constrainedValueJson != null ? constrainedValueJson.asText() : null;
250266
break;
251267
default:
252268
PropertyDescriptor property = JavaBeanHelper.getBeanProperties(data).get(primitiveConstraint.getProperty());
253269
if (property == null) {
254270
return false;
255271
}
256272
if (SUPPORTED_PRIMITIVE_CONSTRAINT_CLASSES.stream()
257-
.noneMatch(supported -> supported.isAssignableFrom(property.getPropertyType()))) {
273+
.anyMatch(supported -> supported.isAssignableFrom(property.getPropertyType()))) {
274+
actualValue = JavaBeanHelper.getBeanPropertyValue(data, property);
275+
constrainedValue = JavaBeanHelper.convert(
276+
constrainedValueJson != null ? constrainedValueJson.asText() : null,
277+
property.getPropertyType()
278+
);
279+
} else if (Data.class.isAssignableFrom(property.getPropertyType())) {
280+
Object _actualValue = JavaBeanHelper.getBeanPropertyValue(data, property);
281+
actualValue = _actualValue != null ? ((Data) _actualValue).getId() : null;
282+
constrainedValue = constrainedValueJson != null ?
283+
JavaBeanHelper.convert(
284+
// intentionally `textValue` instead of `asText` to get a null value for
285+
// improved error reporting
286+
constrainedValueJson.path("@id").textValue(),
287+
UUID.class
288+
) : null;
289+
if (constrainedValue == null) {
290+
throw new IllegalArgumentException();
291+
}
292+
} else {
258293
return false;
259294
}
260-
actualValue = JavaBeanHelper.getBeanPropertyValue(data, property);
261-
constrainedValue = JavaBeanHelper.convert(primitiveConstraint.getValue(), property.getPropertyType());
262295
break;
263296
}
264297
if (actualValue == null || constrainedValue == null) {

app/javabean/UuidPropertyEditor.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* SysML v2 REST/HTTP Pilot Implementation
3+
* Copyright (C) 2022-2023 Twingineer LLC
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*/
20+
121
package javabean;
222

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

828
@Override
929
public void setAsText(String text) throws IllegalArgumentException {
10-
setValue(UUID.fromString(text));
30+
setValue(text != null ? UUID.fromString(text) : null);
1131
}
1232
}

app/org/omg/sysml/lifecycle/impl/package-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
@MetaValue(value = "PortConjugation", targetEntity = PortConjugationImpl.class),
151151
@MetaValue(value = "PortDefinition", targetEntity = PortDefinitionImpl.class),
152152
@MetaValue(value = "PortUsage", targetEntity = PortUsageImpl.class),
153-
@MetaValue(value = "PortioningFeature", targetEntity = PortioningFeatureImpl.class),
154153
@MetaValue(value = "Predicate", targetEntity = PredicateImpl.class),
155154
@MetaValue(value = "Redefinition", targetEntity = RedefinitionImpl.class),
156155
@MetaValue(value = "ReferenceSubsetting", targetEntity = ReferenceSubsettingImpl.class),

app/org/omg/sysml/metamodel/FlowConnectionDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
import java.util.List;
2727
import java.util.Set;
2828

29-
public interface FlowConnectionDefinition extends Interaction, ActionDefinition, ConnectionDefinition, SysMLType {
29+
public interface FlowConnectionDefinition extends Interaction, ConnectionDefinition, ActionDefinition, SysMLType {
3030

3131
}

app/org/omg/sysml/metamodel/MembershipExpose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
import java.util.List;
2727
import java.util.Set;
2828

29-
public interface MembershipExpose extends Expose, MembershipImport, SysMLType {
29+
public interface MembershipExpose extends MembershipImport, Expose, SysMLType {
3030

3131
}

app/org/omg/sysml/metamodel/OccurrenceUsage.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
public interface OccurrenceUsage extends Usage, SysMLType {
3030
List<? extends Class> getOccurrenceDefinition();
3131

32-
PortioningFeature getPortioningFeature();
33-
3432
OccurrenceDefinition getIndividualDefinition();
3533

3634
Boolean getIsIndividual();

app/org/omg/sysml/metamodel/PortioningFeature.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/org/omg/sysml/metamodel/impl/AcceptActionUsageImpl.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,27 +2552,6 @@ public void setPortionKind(PortionKind portionKind) {
25522552

25532553

25542554

2555-
// @info.archinnov.achilles.annotations.Transient
2556-
// @info.archinnov.achilles.annotations.Column("portioningFeature")
2557-
private PortioningFeature portioningFeature;
2558-
2559-
@JsonGetter
2560-
@JsonSerialize(using = DataSerializer.class)
2561-
// @javax.persistence.Transient
2562-
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
2563-
@JoinColumn(name = "portioningFeature_id", table = "AcceptActionUsage")
2564-
public PortioningFeature getPortioningFeature() {
2565-
return portioningFeature;
2566-
}
2567-
2568-
@JsonSetter
2569-
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
2570-
public void setPortioningFeature(PortioningFeature portioningFeature) {
2571-
this.portioningFeature = portioningFeature;
2572-
}
2573-
2574-
2575-
25762555
// @info.archinnov.achilles.annotations.Transient
25772556
// @info.archinnov.achilles.annotations.Column("qualifiedName")
25782557
private String qualifiedName;

app/org/omg/sysml/metamodel/impl/ActionUsageImpl.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,27 +2510,6 @@ public void setPortionKind(PortionKind portionKind) {
25102510

25112511

25122512

2513-
// @info.archinnov.achilles.annotations.Transient
2514-
// @info.archinnov.achilles.annotations.Column("portioningFeature")
2515-
private PortioningFeature portioningFeature;
2516-
2517-
@JsonGetter
2518-
@JsonSerialize(using = DataSerializer.class)
2519-
// @javax.persistence.Transient
2520-
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
2521-
@JoinColumn(name = "portioningFeature_id", table = "ActionUsage")
2522-
public PortioningFeature getPortioningFeature() {
2523-
return portioningFeature;
2524-
}
2525-
2526-
@JsonSetter
2527-
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
2528-
public void setPortioningFeature(PortioningFeature portioningFeature) {
2529-
this.portioningFeature = portioningFeature;
2530-
}
2531-
2532-
2533-
25342513
// @info.archinnov.achilles.annotations.Transient
25352514
// @info.archinnov.achilles.annotations.Column("qualifiedName")
25362515
private String qualifiedName;

app/org/omg/sysml/metamodel/impl/AllocationUsageImpl.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,27 +2663,6 @@ public void setPortionKind(PortionKind portionKind) {
26632663

26642664

26652665

2666-
// @info.archinnov.achilles.annotations.Transient
2667-
// @info.archinnov.achilles.annotations.Column("portioningFeature")
2668-
private PortioningFeature portioningFeature;
2669-
2670-
@JsonGetter
2671-
@JsonSerialize(using = DataSerializer.class)
2672-
// @javax.persistence.Transient
2673-
@Any(metaDef = "PortioningFeatureMetaDef", metaColumn = @javax.persistence.Column(name = "portioningFeature_type"), fetch = FetchType.LAZY)
2674-
@JoinColumn(name = "portioningFeature_id", table = "AllocationUsage")
2675-
public PortioningFeature getPortioningFeature() {
2676-
return portioningFeature;
2677-
}
2678-
2679-
@JsonSetter
2680-
@JsonDeserialize(using = DataDeserializer.class, as = PortioningFeatureImpl.class)
2681-
public void setPortioningFeature(PortioningFeature portioningFeature) {
2682-
this.portioningFeature = portioningFeature;
2683-
}
2684-
2685-
2686-
26872666
// @info.archinnov.achilles.annotations.Transient
26882667
// @info.archinnov.achilles.annotations.Column("qualifiedName")
26892668
private String qualifiedName;

0 commit comments

Comments
 (0)