Skip to content

Commit

Permalink
Merge pull request #393 from DataInMotion/dynamic_service
Browse files Browse the repository at this point in the history
Dynamic service
  • Loading branch information
juergen-albert committed May 7, 2024
2 parents 87710fa + 66291bc commit 1cfdb79
Show file tree
Hide file tree
Showing 42 changed files with 1,443 additions and 354 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ public interface Modelled {

boolean isAutoDelete();

/**
* Indicates if this is loaded Model, which is not allowed to be changed. Any
* changes to this model will result in an Exception. TODO: What kind of
* Exception?
*/
boolean isFrozen();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Used to define a schema for generic device access with no model (e.g. driven
* by configuration)
*/
public final class GenericDto extends BaseValueDto {
public class GenericDto extends BaseValueDto {

public Class<?> type;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*********************************************************************
* Copyright (c) 2022 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Kentyou - initial implementation
**********************************************************************/
package org.eclipse.sensinact.core.emf.dto;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.sensinact.core.annotation.dto.Model;
import org.eclipse.sensinact.core.annotation.dto.Service;
import org.eclipse.sensinact.core.push.dto.GenericDto;
import org.eclipse.sensinact.model.core.provider.DynamicProvider;

/**
* A special update dto type. This is for the export mode, where you can work
* directly with known EMF Models
*/
public final class EMFGenericDto extends GenericDto {

/** The {@link EClass} of the provider */
@Model
public EClass modelEClass;

/**
* The {@link EClass} of a service. This must be set, when updating a
* {@link DynamicProvider}, where a service might not be available yet.
*/
@Service
public EClass serviceEClass;

/**
* The {@link EReference} to the service to set. Can be null if service is
* available.
*/
@Service
public EReference serviceReference;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*********************************************************************
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors: Kentyou - initial implementation
**********************************************************************/
@org.osgi.annotation.bundle.Export
@org.osgi.annotation.versioning.Version("0.2.0")
package org.eclipse.sensinact.core.emf.dto;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
package org.eclipse.sensinact.core.emf.twin;

import java.util.List;
import java.util.Map;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.sensinact.core.twin.SensinactProvider;
import org.eclipse.sensinact.model.core.provider.Provider;
import org.osgi.util.promise.Promise;
Expand All @@ -36,4 +38,19 @@ public interface SensinactEMFProvider extends SensinactProvider {
* @return
*/
Promise<Void> update(Provider newVersion);

/**
* The digital twins for the services for this provider
*
* @return
*/
Map<String, ? extends SensinactEMFService> getServices();

/**
* The digital twins for the service with the given name for this provider A new
* Instance will be create if non exists.
*
* @return
*/
SensinactEMFService getOrCreateService(String name, EClass serviceEClass);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*********************************************************************
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Kentyou - initial implementation
**********************************************************************/
package org.eclipse.sensinact.core.emf.twin;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.sensinact.core.twin.SensinactService;

/**
* The digital twin of a Service instance
*/
public interface SensinactEMFService extends SensinactService {

EClass getServiceEClass();
}
1 change: 1 addition & 0 deletions core/impl/integration-test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
org.eclipse.sensinact.gateway.core.impl-tests;version='[0.0.2,0.0.3)',\
org.eclipse.sensinact.gateway.core.models.metadata;version='[0.0.2,0.0.3)',\
org.eclipse.sensinact.gateway.core.models.provider;version='[0.0.2,0.0.3)',\
org.eclipse.sensinact.gateway.core.models.testdata;version='[0.0.2,0.0.3)',\
org.gecko.emf.osgi.component.minimal;version='[6.1.0,6.1.1)',\
org.mockito.junit-jupiter;version='[5.10.0,5.10.1)',\
org.mockito.mockito-core;version='[5.10.0,5.10.1)',\
Expand Down
5 changes: 5 additions & 0 deletions core/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<artifactId>metadata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}.models</groupId>
<artifactId>testdata</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@

import java.time.Instant;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.sensinact.model.core.provider.Provider;

public abstract class AbstractUpdateDto {

/**
* The package URI of the model to use, if null then a unique package URI will be derived from the model name
* The package URI of the model to use, if null then a unique package URI will
* be derived from the model name
*/
public String modelPackageUri;

Expand Down Expand Up @@ -50,4 +55,16 @@ public abstract class AbstractUpdateDto {
* The original object which this update is derived from
*/
public Object originalDto;

public EClass modelEClass;

/**
* The services {@link EClass}, optional
*/
public EClass serviceEClass;

/**
* The services {@link EReference} on the {@link Provider} model, optional
*/
public EReference serviceReference;
}

0 comments on commit 1cfdb79

Please sign in to comment.