Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Conceptual improvements for namespace #425

Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.eclipse.esmf.metamodel;

/**
* A Namespace is Structure Element for describing namespace and providing user readable information about Namespace.
*
* @since SAMM 2.2.0
*/
public interface Namespace extends StructureElement {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not extends StructureElement; since it does not have Properties like Aspects and Entities.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.eclipse.esmf.metamodel.impl;

import java.util.List;

import org.eclipse.esmf.metamodel.Namespace;
import org.eclipse.esmf.metamodel.Property;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;

public class DefaultNamespace extends ModelElementImpl implements Namespace {

public DefaultNamespace( final MetaModelBaseAttributes metaModelBaseAttributes ) {
super( metaModelBaseAttributes );
}

@Override
public List<Property> getProperties() {
return null;
}

@Override
public <T, C> T accept( AspectVisitor<T, C> visitor, C context ) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.eclipse.esmf.metamodel.loader.instantiator.ListInstantiator;
import org.eclipse.esmf.metamodel.loader.instantiator.LocaleConstraintInstantiator;
import org.eclipse.esmf.metamodel.loader.instantiator.MeasurementInstantiator;
import org.eclipse.esmf.metamodel.loader.instantiator.NamespaceInstantiator;
import org.eclipse.esmf.metamodel.loader.instantiator.OperationInstantiator;
import org.eclipse.esmf.metamodel.loader.instantiator.PropertyInstantiator;
import org.eclipse.esmf.metamodel.loader.instantiator.QuantifiableInstantiator;
Expand Down Expand Up @@ -102,6 +103,7 @@ public ModelElementFactory( final KnownVersion metaModelVersion, final Model mod
registerInstantiator( samm.Event(), new EventInstantiator( this ) );
registerInstantiator( samm.Operation(), new OperationInstantiator( this ) );
registerInstantiator( samm.Property(), new PropertyInstantiator( this ) );
registerInstantiator( samm.Namespace(), new NamespaceInstantiator( this) );

registerInstantiator( sammc.Code(), new CodeInstantiator( this ) );
registerInstantiator( sammc.Collection(), new CollectionInstantiator( this ) );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.eclipse.esmf.metamodel.loader.instantiator;

import org.apache.jena.rdf.model.Resource;
import org.eclipse.esmf.metamodel.Namespace;
import org.eclipse.esmf.metamodel.impl.DefaultNamespace;
import org.eclipse.esmf.metamodel.loader.Instantiator;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.loader.ModelElementFactory;

public class NamespaceInstantiator extends Instantiator<Namespace> {

public NamespaceInstantiator( final ModelElementFactory modelElementFactory ) {
super( modelElementFactory, Namespace.class );
}

@Override
public Namespace apply( final Resource namespace ) {
final MetaModelBaseAttributes metaModelBaseAttributes = buildBaseAttributes( namespace );
return new DefaultNamespace( metaModelBaseAttributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ public Resource Aspect() {
return resource( "Aspect" );
}

public Resource Namespace() {
return resource( "Namespace" );
}

public Property properties() {
return property( "properties" );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ ImmutableList.<String> builder().addAll( queryFilesForAllMetaModelVersions )
.addAll( queryFilesForMetaModelVersionsAsOf2_0_0 )
.build() );

//TODO: Add new version of SAMM 2.2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be necessary if #407 is merged before.


ARQ.init();
model = versionedModel.getModel();
metaModelVersion = KnownVersion.fromVersionString( versionedModel.getMetaModelVersion().toString() )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 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

prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0/boxmodel#>
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>

# Generates boxes for Abstract Entities
construct {
?abstractEntityBox a :Box .
?abstractEntityBox :prototype "Abstract Entity" .
?abstractEntityBox :title ?abstractEntityName .
?abstractEntityBox :modelElement ?abstractEntity .
?abstractEntityBox :entries (
[
a :Entry ;
:title "preferredName" ;
:text ?preferredName
]
[
a :Entry ;
:title "description" ;
:text ?description
]
[
a :Entry ;
:title "see" ;
:text ?seeValues
]
)
} where {
?abstractEntity rdf:type samm:AbstractEntity .
bind( strafter( str( ?abstractEntity ), "#" ) as ?abstractEntityName )

bind( concat( ?abstractEntityName, "AbstractEntity" ) as ?boxName )
bind( iri( concat( func:getNamespace( ?abstractEntity ), ?boxName ) ) as ?abstractEntityBox )

optional {
?abstractEntity samm:preferredName ?preferredNameValue .
filter( lang( ?preferredNameValue ) = "en" )
bind( xsd:string( ?preferredNameValue ) as ?preferredName )
}

optional {
?abstractEntity samm:description ?descriptionValue .
filter( lang( ?descriptionValue ) = "en" )
bind( xsd:string( ?descriptionValue ) as ?description )
}

optional {
{
select ( group_concat( ?seeValue; separator=", " ) as ?seeValues ) ?abstractEntity
where {
select *
where {
?abstractEntity rdf:type samm:AbstractEntity .
?abstractEntity samm:see ?seeValue .
}
order by str( ?seeValue )
}
group by ?abstractEntity
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 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

prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#>
prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.1.0#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0/boxmodel#>
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>

# Generates boxes for Properties
construct {
?propertyBox a :Box .
?propertyBox :prototype "AbstractProperty" .
?propertyBox :title ?propertyName .
?propertyBox :modelElement ?property .
?propertyBox :entries (
[
a :Entry ;
:title "preferredName" ;
:text ?preferredName
]
[
a :Entry ;
:title "description" ;
:text ?description
]
[
a :Entry ;
:title "see" ;
:text ?seeValues
]
)
} where {
#process Properties defined in the Aspect Model being processed
{
?property rdf:type samm:AbstractProperty .
bind( strafter( str( ?property ), "#" ) as ?propertyName ) .

bind( concat( ?propertyName, "AbstractProperty" ) as ?boxName )
bind( iri( concat( func:getNamespace( ?property ), ?boxName ) ) as ?propertyBox )

optional {
?property samm:preferredName ?preferredNameValue .
filter( lang( ?preferredNameValue ) = "en" )
bind( xsd:string( ?preferredNameValue ) as ?preferredName )
}

optional {
?property samm:description ?descriptionValue .
filter( lang( ?descriptionValue ) = "en" )
bind( xsd:string( ?descriptionValue ) as ?description )
}

#subquery which concatenates all values for the samm:see attributes
optional {
select * where {
?property rdf:type samm:Property .
filter( str( ?subQueryProperty ) = str( ?property ) )
{
select ?subQueryProperty ( group_concat( ?seeValue; separator=", " ) as ?seeValues )
where {
select *
where {
?subQueryProperty rdf:type samm:Property .
?subQueryProperty samm:see ?seeValue .
}
order by str( ?seeValue )
}
group by ?subQueryProperty
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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

prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0/boxmodel#>
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>

# Generate edges between Aspects and Operations
construct {
?edge a :Edge .
?edge :title "operation" .
?edge :from ?from .
?edge :to ?to .
} where {
?aspect a samm:Aspect .
bind( strafter( str( ?aspect ), "#" ) as ?aspectName ) .
?operation a samm:Operation .
bind( strafter( str( ?operation ), "#" ) as ?operationName ) .
filter( exists { ?aspect samm:operations/rdf:rest*/rdf:first ?operation } )

bind( concat( ?aspectName, "Aspect" ) as ?aspectBoxName )
bind( iri( concat( func:getNamespace( ?aspect ), ?aspectBoxName ) ) as ?from )
bind( concat( ?operationName, "Operation" ) as ?operationBoxName )
bind( iri( concat( func:getNamespace( ?operation ), ?operationBoxName ) ) as ?to )

bind( iri( concat( func:getNamespace( ?aspect ), ?aspectBoxName, "_To_", ?operationBoxName ) ) as ?edge )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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

prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0#>
prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.1.0#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix : <urn:samm:org.eclipse.esmf.samm:meta-model:2.1.0/boxmodel#>
prefix func: <urn:samm:org.eclipse.esmf.samm:function:2.0.0#>

# Generates edges between Aspects or Entities or Abstract Entities and Properties
construct {
?edge a :Edge .
?edge :title ?title .
?edge :from ?from .
?edge :to ?to .
} where {
# Aspect/Entity/Abstract Entity -> Property Edges (properties)
?aspectOrEntityOrAbstractEntity rdf:type ?class .
filter( ?class in ( samm:Aspect, samm:Entity, samm:AbstractEntity ) )

bind( strafter( str( ?aspectOrEntityOrAbstractEntity ), "#" ) as ?aspectOrEntityOrAbstractEntityName ) .

?property rdf:type ?propertyClass .
filter( ?propertyClass in ( samm:Property, samm:AbstractProperty ) )

bind( strafter( str( ?property ), "#" ) as ?propertyName ) .
filter( exists { ?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first/samm:property? ?property } )

bind( str( ?class ) as ?fullClassName )
bind( strafter( ?fullClassName, "#" ) as ?typeName )
bind( concat( ?aspectOrEntityOrAbstractEntityName, ?typeName ) as ?aspectOrEntityOrAbstractEntityBoxName )
bind( iri( concat( func:getNamespace( ?aspectOrEntityOrAbstractEntity ), ?aspectOrEntityOrAbstractEntityBoxName ) ) as ?from )

bind( if( exists { ?property a samm:AbstractProperty }, "AbstractProperty", "Property" ) as ?propertyClassName )
bind( concat( ?propertyName, ?propertyClassName ) as ?propertyBoxName )
bind( iri( concat( func:getNamespace( ?property ), ?propertyBoxName ) ) as ?to )

bind( iri( concat( func:getNamespace( ?aspectOrEntityOrAbstractEntity ), ?aspectOrEntityOrAbstractEntityBoxName, "_To_", ?propertyBoxName ) ) as ?edge )

optional {
?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
?propertyNode samm:property ?property .
?propertyNode samm:optional true .
?propertyNode samm:payloadName ?payloadName
bind( concat( "property (optional) (", str( ?payloadName ), ")" ) as ?title )
}

optional {
?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
?propertyNode samm:property ?property .
?propertyNode samm:optional true .
bind( "property (optional)" as ?title )
}

optional {
?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
?propertyNode samm:property ?property .
?propertyNode samm:notInPayload true .
bind( "property (not in payload)" as ?title )
}

optional {
?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
?propertyNode samm:property ?property .
?propertyNode samm:payloadName ?payloadName
bind( concat( "property (", str( ?payloadName ), ")" ) as ?title )
}

optional {
?aspectOrEntityOrAbstractEntity samm:properties/rdf:rest*/rdf:first ?propertyNode .
bind( "property" as ?title )
}
}
Loading
Loading