dataClay Mf2c a developers guide for modelling CIMI resources - mF2C/dataClay GitHub Wiki
Welcome!
This wiki is intended to help developers to create/modify/delete CIMI resources in dataClay mf2c model. As a developer you will be able to directly modify dataClay model and generate dataClay Mf2c dockers so you can test what you need in your component. Once you have defined/tested your changes, you will be able to do a pull-request and dataClay team will release a new dataClay-Mf2c docker image if accepted.
1. Changing the model
The first thing you need to do as a developer is to modify the dataClay resource model. For that you should modify the corresponding classes in https://github.com/mF2C/dataClay/tree/master/data_management/model/src/CIMI. Each resource is represented as a Java class. Take into account the following:
An attribute for each field in the CIMI resource spec, with the same name and type, and:
-
If it contains nested info or its a href, it is implemented as a Map<String, Object>
-
If you want your class to be shared/visible in the Leader, please annotate the class with
@ReplicateInLeader
(example: https://github.com/mF2C/dataClay/blob/master/data_management/model/src/CIMI/DeviceDynamic.java) -
if you want to synchronize a specific field with agent leader, add following annotations to your field:
@Replication.InMaster
and@Replication.AfterUpdate(method = "replicateToDataClaysObjectIsFederatedWith", clazz = "dataclay.util.replication.SequentialConsistency")
-
WARNING: All fields must be public or no modifier defined.
-
All types defined must be Object types (Integer,, List...) and not primitive types (int,...) WARNING!!: Use Double for floating point numbers due to JSON restrictions
2. Creating dataClay docker images for testing (only if you want to test it)
Once your model is properly defined, you probably would like to test it in your component. In order to do that we have created a script that builds the new docker images for you. For that you need the following requirements:
- java jdk 1.8
- maven
- docker-compose
- docker
- leiningen
Please, run the script https://github.com/mF2C/dataClay/blob/master/data_management/release.sh with the tag of your docker-image (for instance, if current version is dataclay 2.15, provide 2.16):
bash release.sh 2.16
This will create the following docker-images:
- mf2c/dataclay-logicmodule:${TAG}
- mf2c/dataclay-logicmodule:latest
- mf2c/dataclay-dsjava:${TAG}
- mf2c/dataclay-dsjava:latest
- mf2c/dataclay-proxy:${TAG}
- mf2c/dataclay-proxy:latest
where TAG is the tag you provided.
3. Integrating in dataClay automatic tests
dataClay has some automatized tests that read a set of JSONs files from a folder and create/read cimi resources using them. The folder is located here: https://github.com/mF2C/dataClay/tree/master/data_management/tests/jsons
If you changed a resource, it would be a good practice to change the JSON file in jsons folder. If you added a new resource, it would be a good practice to add a new json file. Note that you don't need to add "CIMI" fields (acls, resourceId,...) in the json files because they are optional in the dataClay testing system.
4. Final steps
Once you have tested that the model is working properly with your changes, do a PR in GitHub and dataClay team will check and publish new docker images and maven JARs for you. Once the PR is accepted you will be able to see which docker image version was released with your changes.
If you have any question or any suggestion, contact [email protected]