-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: - Add new aas command for generating ASPECT from aasx files.
- Loading branch information
1 parent
f9381ae
commit 7034dbd
Showing
11 changed files
with
1,130 additions
and
0 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
...-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/entity/AspectEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* | ||
* See the AUTHORS file(s) distributed with this work for additional | ||
* information regarding authorship. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package org.eclipse.esmf.metamodel.entity; | ||
|
||
import org.eclipse.esmf.metamodel.Aspect; | ||
import org.eclipse.esmf.metamodel.Event; | ||
import org.eclipse.esmf.metamodel.Operation; | ||
import org.eclipse.esmf.metamodel.Property; | ||
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes; | ||
import org.eclipse.esmf.metamodel.visitor.AspectVisitor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.StringJoiner; | ||
|
||
public class AspectEntity extends ModelEntityImpl implements Aspect { | ||
private List<Property> properties; | ||
private List<Operation> operations; | ||
private List<Event> events; | ||
private boolean isCollectionAspect; | ||
|
||
public AspectEntity(final MetaModelBaseAttributes metaModelBaseAttributes, | ||
List<PropertyEntity> properties, | ||
List<OperationEntity> operations, | ||
List<EventEntity> events, | ||
boolean isCollectionAspect ) { | ||
super( metaModelBaseAttributes ); | ||
this.properties = new ArrayList<>( properties ); | ||
this.operations = new ArrayList<>( operations ); | ||
this.events = new ArrayList<>( events ); | ||
this.isCollectionAspect = isCollectionAspect; | ||
} | ||
|
||
public AspectEntity(MetaModelBaseAttributes metaModelBaseAttributes) { | ||
super(metaModelBaseAttributes); | ||
} | ||
|
||
/** | ||
* A list of Properties exposed by the Aspect. | ||
* | ||
* @return the properties. | ||
*/ | ||
@Override | ||
public List<Property> getProperties() { | ||
return properties; | ||
} | ||
|
||
/** | ||
* A list of Operations exposed by the Aspect. | ||
* | ||
* @return the operations. | ||
*/ | ||
@Override | ||
public List<Operation> getOperations() { | ||
return operations; | ||
} | ||
|
||
/** | ||
* A list of Events provided by the Aspect. | ||
* | ||
* @return the events. | ||
*/ | ||
@Override | ||
public List<Event> getEvents() { | ||
return events; | ||
} | ||
|
||
/** | ||
* Accepts an Aspect visitor | ||
* | ||
* @param visitor The visitor to accept | ||
* @param <T> The result type of the traversal operation | ||
* @param <C> The context of the visitor traversal | ||
*/ | ||
@Override | ||
public <T, C> T accept( final AspectVisitor<T, C> visitor, final C context ) { | ||
return visitor.visitAspect( this, context ); | ||
} | ||
|
||
@Override | ||
public boolean isCollectionAspect() { | ||
return isCollectionAspect; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringJoiner( ", ", AspectEntity.class.getSimpleName() + "[", "]" ) | ||
.add( "properties=" + properties ) | ||
.add( "operations=" + operations ) | ||
.add( "events=" + events ) | ||
.add( "isCollectionAspect=" + isCollectionAspect ) | ||
.toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals( final Object o ) { | ||
if ( this == o ) { | ||
return true; | ||
} | ||
if ( o == null || getClass() != o.getClass() ) { | ||
return false; | ||
} | ||
if ( !super.equals( o ) ) { | ||
return false; | ||
} | ||
final AspectEntity that = (AspectEntity) o; | ||
return isCollectionAspect == that.isCollectionAspect && | ||
Objects.equals( properties, that.properties ) && | ||
Objects.equals( operations, that.operations ) && | ||
Objects.equals( events, that.events ); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash( super.hashCode(), properties, operations, events, isCollectionAspect ); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...meta-model-java/src/main/java/org/eclipse/esmf/metamodel/entity/CharacteristicEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* | ||
* See the AUTHORS file(s) distributed with this work for additional | ||
* information regarding authorship. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package org.eclipse.esmf.metamodel.entity; | ||
|
||
import org.eclipse.esmf.metamodel.Characteristic; | ||
import org.eclipse.esmf.metamodel.Type; | ||
import org.eclipse.esmf.metamodel.impl.ModelElementImpl; | ||
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes; | ||
import org.eclipse.esmf.metamodel.visitor.AspectVisitor; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.StringJoiner; | ||
|
||
public class CharacteristicEntity extends ModelEntityImpl implements Characteristic { | ||
private final Optional<Type> dataType; | ||
|
||
public CharacteristicEntity(final MetaModelBaseAttributes metaModelBaseAttributes, final Optional<Type> dataType ) { | ||
super( metaModelBaseAttributes ); | ||
this.dataType = dataType; | ||
} | ||
|
||
/** | ||
* Defines the data type of all Properties which use this Characteristic. | ||
* | ||
* @return the dataType. | ||
*/ | ||
@Override | ||
public Optional<Type> getDataType() { | ||
return dataType; | ||
} | ||
|
||
/** | ||
* Accepts an Aspect visitor | ||
* | ||
* @param visitor The visitor to accept | ||
* @param <T> The result type of the traversal operation | ||
* @param <C> The context of the visitor traversal | ||
*/ | ||
@Override | ||
public <T, C> T accept( final AspectVisitor<T, C> visitor, final C context ) { | ||
return visitor.visitCharacteristic( this, context ); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringJoiner( ", ", CharacteristicEntity.class.getSimpleName() + "[", "]" ) | ||
.add( "dataType=" + dataType ) | ||
.toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals( final Object o ) { | ||
if ( this == o ) { | ||
return true; | ||
} | ||
if ( o == null || getClass() != o.getClass() ) { | ||
return false; | ||
} | ||
return super.equals( o ); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash( super.hashCode() ); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...f-aspect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/entity/EventEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* | ||
* See the AUTHORS file(s) distributed with this work for additional | ||
* information regarding authorship. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.esmf.metamodel.entity; | ||
|
||
import org.eclipse.esmf.metamodel.Event; | ||
import org.eclipse.esmf.metamodel.Property; | ||
import org.eclipse.esmf.metamodel.impl.ModelElementImpl; | ||
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes; | ||
import org.eclipse.esmf.metamodel.visitor.AspectVisitor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class EventEntity extends ModelEntityImpl implements Event { | ||
private List<Property> properties; | ||
|
||
public EventEntity(MetaModelBaseAttributes metaModelBaseAttributes, List<PropertyEntity> properties ) { | ||
super( metaModelBaseAttributes ); | ||
this.properties = new ArrayList<>( properties ); | ||
} | ||
|
||
@Override | ||
public List<Property> getProperties() { | ||
return properties; | ||
} | ||
|
||
/** | ||
* Accepts an Aspect visitor | ||
* | ||
* @param visitor The visitor to accept | ||
* @param <T> The result type of the traversal operation | ||
* @param <C> The context of the visitor traversal | ||
*/ | ||
@Override | ||
public <T, C> T accept( AspectVisitor<T, C> visitor, C context ) { | ||
return visitor.visitEvent( this, context ); | ||
} | ||
|
||
public void setProperties(List<Property> properties) { | ||
this.properties = properties; | ||
} | ||
} |
132 changes: 132 additions & 0 deletions
132
...pect-meta-model-java/src/main/java/org/eclipse/esmf/metamodel/entity/ModelEntityImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
* Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH | ||
* | ||
* See the AUTHORS file(s) distributed with this work for additional | ||
* information regarding authorship. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package org.eclipse.esmf.metamodel.entity; | ||
|
||
import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn; | ||
import org.eclipse.esmf.metamodel.ModelElement; | ||
import org.eclipse.esmf.metamodel.NamedElement; | ||
import org.eclipse.esmf.metamodel.datatypes.LangString; | ||
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes; | ||
import org.eclipse.esmf.samm.KnownVersion; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* The base implemenation of all model elements. | ||
*/ | ||
public abstract class ModelEntityImpl implements ModelElement, NamedElement, Comparable<ModelEntityImpl> { | ||
private KnownVersion metaModelVersion; | ||
private Optional<AspectModelUrn> urn; | ||
private String name; | ||
private Set<LangString> preferredNames; | ||
private Set<LangString> descriptions; | ||
private List<String> see; | ||
private boolean hasSyntheticName; | ||
|
||
ModelEntityImpl(final MetaModelBaseAttributes metaModelBaseAttributes ) { | ||
metaModelVersion = metaModelBaseAttributes.getMetaModelVersion(); | ||
urn = metaModelBaseAttributes.getUrn(); | ||
name = metaModelBaseAttributes.getName(); | ||
preferredNames = metaModelBaseAttributes.getPreferredNames(); | ||
descriptions = metaModelBaseAttributes.getDescriptions(); | ||
see = metaModelBaseAttributes.getSee(); | ||
hasSyntheticName = metaModelBaseAttributes.hasSyntheticName(); | ||
} | ||
|
||
/** | ||
* The URN for the element, if present. Certain elements (such as Constraints) are allowed to not have URNs, which is why the URN is optional. | ||
* | ||
* @return the URN. | ||
*/ | ||
@Override | ||
public Optional<AspectModelUrn> getAspectModelUrn() { | ||
return urn; | ||
} | ||
|
||
/** | ||
* Returns the metamodel version this model element is defined against | ||
*/ | ||
@Override | ||
public KnownVersion getMetaModelVersion() { | ||
return metaModelVersion; | ||
} | ||
|
||
/** | ||
* The name of the element. | ||
* | ||
* @return the name. | ||
*/ | ||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* A language specific name for the Element. There may be multiple preferred names. | ||
* | ||
* @return the preferredNames. | ||
*/ | ||
@Override | ||
public Set<LangString> getPreferredNames() { | ||
return preferredNames; | ||
} | ||
|
||
/** | ||
* A language specific description of the Element. There may be multiple descriptions. | ||
* | ||
* @return the descriptions. | ||
*/ | ||
@Override | ||
public Set<LangString> getDescriptions() { | ||
return descriptions; | ||
} | ||
|
||
@Override | ||
public List<String> getSee() { | ||
return see; | ||
} | ||
|
||
@Override | ||
public boolean hasSyntheticName() { | ||
return hasSyntheticName; | ||
} | ||
|
||
@Override | ||
public boolean equals( Object o ) { | ||
if ( this == o ) { | ||
return true; | ||
} | ||
if ( o == null || getClass() != o.getClass() ) { | ||
return false; | ||
} | ||
ModelEntityImpl base = (ModelEntityImpl) o; | ||
return Objects.equals( urn, base.urn ) && | ||
Objects.equals( name, base.name ); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash( urn, name ); | ||
} | ||
|
||
@Override | ||
public int compareTo( ModelEntityImpl o ) { | ||
if ( this.urn.isPresent() && o.urn.isPresent() ) | ||
return this.urn.get().compareTo( o.urn.get() ); | ||
return Comparator | ||
.comparing( ModelEntityImpl::getMetaModelVersion ) | ||
.thenComparing( ModelEntityImpl::getName ) | ||
.thenComparing( ModelEntityImpl::hasSyntheticName ) | ||
.compare( this, o ); | ||
} | ||
} |
Oops, something went wrong.