Skip to content

Commit 618652a

Browse files
committed
Release 0.4.0 with Storage Layer to support DT's Storage Management and a Query System
1 parent a9e5cbd commit 618652a

12 files changed

Lines changed: 568 additions & 12 deletions

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# WhiteLabel Digital Twin Framework
22

3+
The White Label Digital Twin (WLDT) library aims to support the design, development, and deployment of Digital Twins within the Internet of Things (IoT) ecosystems.
4+
The library has been designed following the latest DT definitions coming from both Industrial and Scientific domains and identifying DTs as active, flexible and scalable software components.
5+
6+
The complete Documentation of the Library is available at the following link: [https://wldt.github.io/](https://wldt.github.io/)
7+
38
## Library Dependency Import
49

510
The official library repository is available at the following link [https://central.sonatype.com/artifact/io.github.wldt/wldt-core/](https://central.sonatype.com/artifact/io.github.wldt/wldt-core/)
@@ -10,14 +15,14 @@ For Maven projects you can import the WLDT Library into your ``<dependencies></d
1015
<dependency>
1116
<groupId>io.github.wldt</groupId>
1217
<artifactId>wldt-core</artifactId>
13-
<version>0.3.0</version>
18+
<version>0.4.0</version>
1419
</dependency>
1520
```
1621

1722
If you are using Gradle use instead the following:
1823

1924
```groovy
20-
implementation group: 'io.github.wldt', name: 'wldt-core', version: '0.3.0'
25+
implementation group: 'io.github.wldt', name: 'wldt-core', version: '0.4.0'
2126
```
2227

2328
## Scientitic Citation & Reference

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file was generated by the Gradle 'init' task.
33
*/
44
group = "io.github.wldt"
5-
version = "0.3.0"
5+
version = "0.4.0"
66
description = "The core library to build White Label Digital Twins"
77
java.sourceCompatibility = JavaVersion.VERSION_1_8
88

@@ -19,7 +19,7 @@ repositories {
1919

2020
dependencies {
2121
api("org.apache.commons:commons-lang3:3.9")
22-
api("ch.qos.logback:logback-classic:1.4.12")
22+
api("ch.qos.logback:logback-classic:1.4.14")
2323
api("javax.inject:javax.inject:1")
2424
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.1")
2525
}
@@ -52,8 +52,8 @@ publishing {
5252
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots"
5353
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
5454
credentials {
55-
username = (properties["ossrhUsername"] as String?)
56-
password = (properties["ossrhPassword"] as String?)
55+
username = (properties["ossrhToken"] as String?)
56+
password = (properties["ossrhTokenPassword"] as String?)
5757
}
5858
}
5959
maven {

src/main/java/it/wldt/storage/DefaultWldtStorage.java

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import it.wldt.core.state.DigitalTwinStateEventNotification;
99
import it.wldt.exception.StorageException;
1010
import it.wldt.adapter.physical.PhysicalAssetPropertyVariation;
11+
import it.wldt.storage.model.StorageRecord;
12+
import it.wldt.storage.model.StorageStats;
13+
import it.wldt.storage.model.StorageStatsRecord;
1114
import it.wldt.storage.model.digital.DigitalActionRequestRecord;
1215
import it.wldt.storage.model.lifecycle.LifeCycleVariationRecord;
1316
import it.wldt.storage.model.physical.*;
@@ -672,9 +675,7 @@ public List<PhysicalAssetDescriptionNotificationRecord> getNewPhysicalAssetDescr
672675

673676
/**
674677
* Save the updated Physical Asset Description
675-
*
676-
* @param physicalAssetDescriptionNotification
677-
* @return the number of Physical Asset Description Available
678+
* @param physicalAssetDescriptionNotification the updated Physical Asset Description
678679
*/
679680
@Override
680681
public void saveUpdatedPhysicalAssetDescriptionNotification(PhysicalAssetDescriptionNotification physicalAssetDescriptionNotification) throws StorageException {
@@ -974,4 +975,50 @@ public List<PhysicalRelationshipInstanceVariationRecord> getPhysicalAssetRelatio
974975
return result;
975976
}
976977

978+
/**
979+
* Get the number stored information of the target Map
980+
* @return th StorageStatsRecord associated to the target Map
981+
*/
982+
private StorageStatsRecord getStorageStatsFromMap(Map<Long, ? extends StorageRecord> targetMap){
983+
984+
StorageStatsRecord storageStatsRecord = new StorageStatsRecord();
985+
storageStatsRecord.setRecordCount(targetMap.size());
986+
987+
if(!targetMap.isEmpty()){
988+
List<Long> timestamps = new ArrayList<>(targetMap.keySet());
989+
storageStatsRecord.setRecordStartTimestampMs(Collections.min(timestamps));
990+
storageStatsRecord.setRecordEndTimestampMs(Collections.max(timestamps));
991+
}
992+
993+
return storageStatsRecord;
994+
}
995+
996+
/**
997+
* Retrieve and returns storage statistics in terms of the number of stored records for each type and the
998+
* associated time range of the stored records (start and end timestamp)
999+
* @return the storage statistics
1000+
* @throws StorageException if an error occurs while retrieving the storage statistics
1001+
*/
1002+
@Override
1003+
public StorageStats getStorageStats() throws StorageException {
1004+
try {
1005+
// Set the StorageStateRecords in the final class
1006+
StorageStats storageStats = new StorageStats();
1007+
storageStats.setStateVariationStats(getStorageStatsFromMap(digitalTwinStateMap));
1008+
storageStats.setLifeCycleVariationStats(getStorageStatsFromMap(lifeCycleStateMap));
1009+
storageStats.setPhysicalAssetPropertyVariationStats(getStorageStatsFromMap(physicalAssetPropertyVariationMap));
1010+
storageStats.setPhysicalAssetEventNotificationStats(getStorageStatsFromMap(physicalEventNotificationsMap));
1011+
storageStats.setPhysicalAssetActionRequestStats(getStorageStatsFromMap(physicalActionRequestMap));
1012+
storageStats.setDigitalActionRequestStats(getStorageStatsFromMap(digitalActionRequestMap));
1013+
storageStats.setNewPhysicalAssetDescriptionNotificationStats(getStorageStatsFromMap(newPhysicalAssetDescriptionNotificationMap));
1014+
storageStats.setUpdatedPhysicalAssetDescriptionNotificationStats(getStorageStatsFromMap(updatedPhysicalAssetDescriptionNotificationMap));
1015+
storageStats.setPhysicalRelationshipInstanceCreatedNotificationStats(getStorageStatsFromMap(physicalRelationshipInstanceCreatedMap));
1016+
storageStats.setPhysicalRelationshipInstanceDeletedNotificationStats(getStorageStatsFromMap(physicalRelationshipInstanceDeletedMap));
1017+
1018+
return storageStats;
1019+
}catch (Exception e){
1020+
throw new StorageException("Error while retrieving the storage statistics: " + e.getMessage());
1021+
}
1022+
}
1023+
9771024
}

src/main/java/it/wldt/storage/WldtStorage.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import it.wldt.core.state.DigitalTwinStateEventNotification;
99
import it.wldt.exception.StorageException;
1010
import it.wldt.adapter.physical.PhysicalAssetPropertyVariation;
11+
import it.wldt.storage.model.StorageStats;
1112
import it.wldt.storage.model.digital.DigitalActionRequestRecord;
1213
import it.wldt.storage.model.lifecycle.LifeCycleVariationRecord;
1314
import it.wldt.storage.model.physical.*;
@@ -390,7 +391,6 @@ public void setStorageId(String storageId) {
390391

391392
/**
392393
* Save the updated Physical Asset Description
393-
* @return the number of Physical Asset Description Available
394394
*/
395395
public abstract void saveUpdatedPhysicalAssetDescriptionNotification(PhysicalAssetDescriptionNotification physicalAssetDescriptionNotification) throws StorageException;
396396

@@ -508,6 +508,14 @@ public void setStorageId(String storageId) {
508508
*/
509509
public abstract List<PhysicalRelationshipInstanceVariationRecord> getPhysicalAssetRelationshipInstanceDeletedNotificationInRange(int startIndex, int endIndex) throws StorageException, IndexOutOfBoundsException, IllegalArgumentException;
510510

511+
/**
512+
* Retrieve and returns storage statistics in terms of the number of stored records for each type and the
513+
* associated time range of the stored records (start and end timestamp)
514+
* @return the storage statistics
515+
* @throws StorageException if an error occurs while retrieving the storage statistics
516+
*/
517+
public abstract StorageStats getStorageStats() throws StorageException;
518+
511519
/**
512520
* Initialize the WLDT Storage
513521
*/

src/main/java/it/wldt/storage/model/StorageRecord.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package it.wldt.storage.model;
22

33
/**
4+
* Author: Marco Picone (picone.m@gmail.com)
5+
* Date: 01/08/2024
46
* Storage Record Class
5-
* Represents a singola record in the storage with a unique id
7+
* Represents a single record in the storage with a unique id
68
*/
79
public class StorageRecord {
810

0 commit comments

Comments
 (0)