Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
45719f3
Add workflow for building documentation
Daespen Nov 19, 2021
48e3f3a
Update documentation with regard to CI
Daespen Nov 19, 2021
13ac472
Fix docfx workflow to remove unnecessary condition
Daespen Nov 19, 2021
dfecd73
Merge pull request #48 from Daespen/feature/docfxworkflow
FrankSchnicke Nov 19, 2021
3a1cb02
fixed bug with de-/serialization of Reference (now using camel case n…
mjacoby Nov 25, 2021
1dfd9d8
- improved versioning schema
mjacoby Nov 25, 2021
b017431
Merge pull request #51 from admin-shell-io/feature/deploy-to-sonatype
sebbader Nov 25, 2021
dd9afc7
fix potential NPE
mjacoby Dec 1, 2021
d05d035
- now serializing AssetInformation.specificAssetId (using custom form…
mjacoby Dec 1, 2021
02455ba
Updates deployment action
FrankSchnicke Jan 25, 2022
e31c54b
Fixes wrong repository reference in docs
FrankSchnicke Jan 25, 2022
3d32a74
Updates POM version to 1.2.1-SNAPSHOT
FrankSchnicke Jan 25, 2022
a127c87
Merge pull request #52 from admin-shell-io/bugfix/aml-serializer
FrankSchnicke Jan 25, 2022
b38c1b0
Merge branch 'bugfix/serialization' into bugfix/reference-deserializa…
FrankSchnicke Jan 25, 2022
4994af4
Fixed simple example to match new enum serialization pattern
mjacoby Jan 25, 2022
70244ad
Merge pull request #50 from admin-shell-io/bugfix/reference-deseriali…
FrankSchnicke Jan 26, 2022
d14bc2e
Updates version to 1.2.1
FrankSchnicke Jan 26, 2022
9879b22
Merge pull request #53 from admin-shell-io/bugfix/serialization
FrankSchnicke Jan 26, 2022
4ef1837
Update README.md
sebbader Feb 9, 2022
da25f0f
clarify docs on development and release process
May 10, 2022
a0d6da4
reintroduce snapshots
May 10, 2022
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
29 changes: 29 additions & 0 deletions .github/workflows/docfx-build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will build and publish documentation with docfx
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path

name: Documentation Publish

on:
push:
branches:
- main

jobs:
build_docs:
runs-on: ubuntu-latest
name: Build and publish documentation
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Build docfx
uses: nikeee/[email protected]
with:
args: docs/docfx.json

- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site
force_orphan: true
4 changes: 2 additions & 2 deletions .github/workflows/maven-deploy-to-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
name: Generate and Deploy to Sonatype

on:
push:
branches: [ main ]
release:
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not match what is in the description, i.e. that a push on main triggers a release to maven central. However, I agreed that we should only trigger releases upon tags to ensure we have properly archived the code base for each release.

types: [published]

jobs:

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ root:

`mvn clean package`


or by integrating the respective modules as dependencies from Maven Central Repository, for instance:

```
Expand Down Expand Up @@ -68,4 +69,4 @@ We always look for contributions, bug reports, feature requests etc. Simply open
| Jan Blume | Fraunhofer IOSB | []() | | | | | | | | | x |

This project was initiated by SAP and Fraunhofer to provide a foundation for the
AAS development and to foster its dissemination.
AAS development and to foster its dissemination.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
import io.adminshell.aas.v3.dataformat.mapping.MappingProvider;
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
import io.adminshell.aas.v3.model.AssetInformation;
import io.adminshell.aas.v3.model.Identifiable;
import io.adminshell.aas.v3.model.MultiLanguageProperty;
import io.adminshell.aas.v3.model.Referable;
import io.adminshell.aas.v3.model.Qualifiable;


import java.util.List;

/**
Expand Down Expand Up @@ -64,8 +64,8 @@ public AssetAdministrationShellEnvironment map(CAEXFile aml) throws MappingExcep
mappingProvider.register(new LangStringCollectionMapper());
mappingProvider.register(new RelationshipElementMapper());
mappingProvider.register(new ReferenceElementMapper());
mappingProvider.register(new ReferableMapper<Referable>());
mappingProvider.register(new IdentifiableMapper<Identifiable>());
mappingProvider.register(new ReferableMapper<>());
mappingProvider.register(new IdentifiableMapper<>());
mappingProvider.register(new ConstraintCollectionMapper());
mappingProvider.register(new QualifierMapper());
mappingProvider.register(new OperationCollectionMapper());
Expand All @@ -77,12 +77,15 @@ public AssetAdministrationShellEnvironment map(CAEXFile aml) throws MappingExcep
mappingProvider.register(new EmbeddedDataSpecificationCollectionMapper());
mappingProvider.register(new DataSpecificationIEC61360Mapper());
mappingProvider.register(new EnumDataTypeIEC61360Mapper());
mappingProvider.register(new IdentifierKeyValuePairCollectionMapper());

AbstractClassNamingStrategy classNamingStrategy = new NumberingClassNamingStrategy();

PropertyNamingStrategy propertyNamingStrategy = new PropertyNamingStrategy();
propertyNamingStrategy.registerCustomNaming(Referable.class, "descriptions", "description");
propertyNamingStrategy.registerCustomNaming(MultiLanguageProperty.class, "values", "value");
propertyNamingStrategy.registerCustomNaming(Qualifiable.class, "qualifiers", "qualifier","qualifier");
propertyNamingStrategy.registerCustomNaming(Qualifiable.class, "qualifiers", "qualifier", "qualifier");
propertyNamingStrategy.registerCustomNaming(AssetInformation.class, "specificAssetIds", "specificAssetId");
MappingContext context = new MappingContext(mappingProvider, classNamingStrategy, propertyNamingStrategy, config.getTypeFactory());
context.setDocumentInfo(AmlDocumentInfo.fromFile(aml));
AssetAdministrationShellEnvironment result = context.map(AssetAdministrationShellEnvironment.class, parser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public AssetAdministrationShellEnvironment map(AmlParser parser, MappingContext
CAEXFile.SystemUnitClassLib systemUnitClassLib = parser.getContent().getSystemUnitClassLib().stream()
.filter(x -> x.getName().equalsIgnoreCase(ASSET_ADMINISTRATION_SHELL_SYSTEM_UNIT_CLASSES))
.findFirst()
.orElse(null);
.orElse(CAEXFile.SystemUnitClassLib.builder().build());

List<SystemUnitFamilyType> systemUnitFamilyTypeShells = systemUnitClassLib.getSystemUnitClass().stream()
.filter(x ->x.getSupportedRoleClass().get(0).getRefRoleClassPath().equalsIgnoreCase(ROLE_CLASS_LIB_ASSET_ADMINISTRATION_SHELL))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.adminshell.aas.v3.dataformat.aml.deserialization.mappers;

import io.adminshell.aas.v3.dataformat.aml.deserialization.AmlParser;
import io.adminshell.aas.v3.dataformat.aml.deserialization.DefaultMapper;
import io.adminshell.aas.v3.dataformat.aml.deserialization.MappingContext;
import io.adminshell.aas.v3.dataformat.aml.model.caex.AttributeType;
import io.adminshell.aas.v3.dataformat.aml.model.caex.CAEXObject;
import io.adminshell.aas.v3.dataformat.core.util.AasUtils;
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
import io.adminshell.aas.v3.model.IdentifierKeyValuePair;
import java.beans.PropertyDescriptor;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class IdentifierKeyValuePairCollectionMapper extends DefaultMapper<Collection<IdentifierKeyValuePair>> {

@Override
protected Collection mapCollectionValueProperty(AmlParser parser, MappingContext context) throws MappingException {
Collection result = new ArrayList<>();
CAEXObject current = parser.getCurrent();
AttributeType parent = findAttribute(current, context.getProperty(), context);
if (parent == null) {
return result;
}
List<AttributeType> attributes = findAttributes(parent, x -> x.getName().startsWith("specificAssetId"));
for (AttributeType attribute : attributes) {
parser.setCurrent(attribute);
try {
IdentifierKeyValuePair element = context.getTypeFactory().newInstance(IdentifierKeyValuePair.class);
for (PropertyDescriptor property : AasUtils.getAasProperties(IdentifierKeyValuePair.class)) {
Object propertyValue = context
.with(element)
.with(property)
.withoutType()
.map(property.getReadMethod().getGenericReturnType(), parser);
if (propertyValue != null) {
try {
property.getWriteMethod().invoke(element, propertyValue);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
throw new MappingException(String.format("error setting property value for property %s", property.getName()), ex);
}
}
}
parser.setCurrent(attribute);
result.add(element);
} catch (NoSuchMethodException ex) {
Logger.getLogger(IdentifierKeyValuePairCollectionMapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(IdentifierKeyValuePairCollectionMapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(IdentifierKeyValuePairCollectionMapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(IdentifierKeyValuePairCollectionMapper.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(IdentifierKeyValuePairCollectionMapper.class.getName()).log(Level.SEVERE, null, ex);
}
}
parser.setCurrent(parent);
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.adminshell.aas.v3.dataformat.aml.serialization.mappers.ViewMapper;
import io.adminshell.aas.v3.dataformat.aml.model.caex.CAEXFile;
import io.adminshell.aas.v3.dataformat.aml.serialization.mappers.ConceptDescriptionMapper;
import io.adminshell.aas.v3.dataformat.aml.serialization.mappers.IdentifierKeyValuePairCollectionMapper;
import io.adminshell.aas.v3.dataformat.aml.serialization.mappers.PropertyMapper;
import io.adminshell.aas.v3.dataformat.aml.serialization.mappers.RangeMapper;
import io.adminshell.aas.v3.dataformat.aml.serialization.mappers.ReferenceMapper;
Expand Down Expand Up @@ -99,6 +100,7 @@ public CAEXFile map(AssetAdministrationShellEnvironment env, AmlSerializationCon
mappingProvider.register(new PropertyMapper());
mappingProvider.register(new RangeMapper());
mappingProvider.register(new ConceptDescriptionMapper());
mappingProvider.register(new IdentifierKeyValuePairCollectionMapper());
MappingContext context = new MappingContext(
mappingProvider,
classNamingStrategy,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.adminshell.aas.v3.dataformat.aml.serialization.mappers;

import io.adminshell.aas.v3.dataformat.aml.serialization.DefaultMapper;
import io.adminshell.aas.v3.dataformat.aml.serialization.AmlGenerator;
import io.adminshell.aas.v3.dataformat.aml.serialization.MappingContext;
import io.adminshell.aas.v3.dataformat.aml.model.caex.AttributeType;
import io.adminshell.aas.v3.dataformat.core.util.AasUtils;
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
import io.adminshell.aas.v3.model.AssetInformation;
import io.adminshell.aas.v3.model.IdentifierKeyValuePair;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class IdentifierKeyValuePairCollectionMapper extends DefaultMapper<Collection<IdentifierKeyValuePair>> {

private static final String ATTRIBUTE_NAME = "specificAssetId";

@Override
public void map(Collection<IdentifierKeyValuePair> value, AmlGenerator generator, MappingContext context) throws MappingException {
if (value == null || context == null || value.isEmpty()) {
return;
}
AttributeType.Builder wrapperBuilder = AttributeType.builder()
.withName(ATTRIBUTE_NAME)
.withRefSemantic(generator.refSemantic(AssetInformation.class, ATTRIBUTE_NAME));
List<AttributeType> attributes = new ArrayList<>();
for (IdentifierKeyValuePair element : value) {
AttributeType.Builder builder = AttributeType.builder()
.withName(ATTRIBUTE_NAME + (value.size() > 1 ? "_" + (attributes.size() + 1) : ""));
for (PropertyDescriptor property : AasUtils.getAasProperties(element.getClass())) {
if (!skipProperty(property)) {
context.with(property)
.map(property.getReadMethod().getGenericReturnType(),
getElemenetPropertyValue(element, property, context),
generator.with(builder));
}
}
attributes.add(builder.build());
}
attributes.forEach(x -> wrapperBuilder.addAttribute(x));
generator.add(wrapperBuilder.build());
}

protected Object getElemenetPropertyValue(IdentifierKeyValuePair elemenet, PropertyDescriptor property, MappingContext context) throws MappingException {
try {
return property.getReadMethod().invoke(elemenet);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
throw new MappingException("failed to get property value for property " + property.getName(), ex);
}
}
}
Loading