Skip to content

Commit

Permalink
Result of Code Generation Run (#11)
Browse files Browse the repository at this point in the history
* rerun the generator on part 2 classes

* remove all *Metadata classes
* fix outdated attributes and cardinalities
* fix inheritence relations between result classes
* remove class SubmodelElementAttributes
* reintroduce Arrays.toString(...) for byte[]
* map duration to javax.xml.datatype.Duration
  • Loading branch information
sebbader-sap authored Jan 19, 2024
1 parent cbfc4d2 commit 1501411
Show file tree
Hide file tree
Showing 74 changed files with 527 additions and 8,202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@
import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXsd;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes;
import org.eclipse.digitaltwin.aas4j.v3.model.OperationRequest;
import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultOperationRequest;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;

public class Examples {

public static final Environment EXTENSION_MINIMAL = new DefaultEnvironment.Builder()
Expand Down Expand Up @@ -78,4 +83,17 @@ public class Examples {
.build())
.build())
.build();

public static OperationRequest OPERATION_REQUEST;
static {
try {
OPERATION_REQUEST = new DefaultOperationRequest.Builder()
.clientTimeoutDuration(DatatypeFactory.newInstance().newDurationDayTime("PT3M")) // three minutes
.build();
} catch (DatatypeConfigurationException e) {
OPERATION_REQUEST = new DefaultOperationRequest.Builder()
.build();
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
* Copyright (C) 2023 SAP SE or an SAP affiliate company.
*
* 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 org.eclipse.digitaltwin.aas4j.v3.dataformat.json;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples;
import org.eclipse.digitaltwin.aas4j.v3.model.OperationRequest;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;

import static org.junit.Assert.assertEquals;

public class JsonDurationDeserializerTest {

private static final Logger logger = LoggerFactory.getLogger(JsonDurationDeserializerTest.class);

String operationRequestString;

@Before
public void prepare() throws SerializationException, JsonProcessingException {

operationRequestString = new ObjectMapper().writeValueAsString(Examples.OPERATION_REQUEST);

}


@Test
public void testDeserializeDuration() throws DeserializationException, DatatypeConfigurationException {

Duration duration = DatatypeFactory.newInstance().newDurationDayTime("P0DT0H3M0S"); // three minutes

JsonDeserializer deserializer = new JsonDeserializer();

OperationRequest operationRequest = deserializer.read(operationRequestString, OperationRequest.class);

assertEquals( operationRequest.getClientTimeoutDuration() , duration);
}


}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
* Copyright (c) 2023, SAP SE or an SAP affiliate company
*
* 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 org.eclipse.digitaltwin.aas4j.v3.model;


import org.eclipse.digitaltwin.aas4j.v3.model.annotations.IRI;
import org.eclipse.digitaltwin.aas4j.v3.model.annotations.KnownSubtypes;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultBaseOperationResult;


/**
*/
@KnownSubtypes({
@KnownSubtypes.Type(value = DefaultBaseOperationResult.class)
})
public interface BaseOperationResult extends Result {

/**
*
* More information under https://admin-shell.io/aas/3/0/BaseOperationResult/executionState
*
* @return Returns the ExecutionState for the property executionState.
*/
@IRI("https://admin-shell.io/aas/3/0/BaseOperationResult/executionState")
ExecutionState getExecutionState();

/**
*
* More information under https://admin-shell.io/aas/3/0/BaseOperationResult/executionState
*
* @param executionState desired value for the property executionState.
*/
void setExecutionState(ExecutionState executionState);

/**
*
* More information under https://admin-shell.io/aas/3/0/BaseOperationResult/success
*
* @return Returns the boolean for the property success.
*/
@IRI("https://admin-shell.io/aas/3/0/BaseOperationResult/success")
boolean getSuccess();

/**
*
* More information under https://admin-shell.io/aas/3/0/BaseOperationResult/success
*
* @param success desired value for the property success.
*/
void setSuccess(boolean success);

}
Loading

0 comments on commit 1501411

Please sign in to comment.