-
Notifications
You must be signed in to change notification settings - Fork 1
Simple Example
Now that you've successfully configured the environment, we can start using the LinkedUSDL Pricing API!
Suppose we're trying to describe a Cloud Service provided by a business entity. The service has some characteristics and, the customer is able to rent/use it in exchange for a fee. For this particular example, suppose the customer is charged a single fee for each month he used/rented the service.
To create a semantic description of the Service, you only need to follow these three steps:
- Step 1 - Create an instance of the Service class and populate it with some features/attributes.
- Step 2 - Create an instance of the Offering class, link the created Service and define its Price Plan.
- Step 3 - Call the WriteToModel() function to create the Sematic (RDF/Turtle) representation of the Service.
First, we need to create an object to represent Service and its features. This is done by the Service class:
//Offerings container
LinkedUSDLModel jmodel;
jmodel = LinkedUSDLModelFactory.createEmptyModel();
Service serv1 = new Service();// create an empty service
serv1.setName("Service1");
serv1.setComment("This is an imaginary service.");
Now that we have a container for the Service features, we can create and link them to the Service instance. The API considers two different types of features:
- Qualitative Features - Their value is a String.
- Quantitative Features - Their value can be quantified ( e.g: MemorySize or CPU Speed ) thus, their value is a double.
Each feature needs a type to give some kind of meaning to its value. To achieve this, the API includes the CLOUDEnum which helps us pick the appropriate type for the feature at hand. For this example, let's consider the following features for the service:
-
Qualitative Features:
- Location
- Windows
- Performance
-
Quantitative Features:
- Availability
- DiskSize
- MemorySize
- Qualitative Features Description
QualitativeValue qualfeat1 = new QualitativeValue();
QualitativeValue qualfeat2 = new QualitativeValue();
QualitativeValue qualfeat3 = new QualitativeValue();
qualfeat1.addType(CLOUDEnum.PERFORMANCE.getConceptURI());//feature type, CloudTaxonomy-> Performance
qualfeat1.setComment("Feature that specifies the performance of the service");//feature comment
qualfeat1.setHasLabel("High");//feature value
serv1.addQualFeature(qualfeat1);//add the feature to the service
qualfeat2.addType(CLOUDEnum.LOCATION.getConceptURI());
qualfeat2.setComment("Feature that specifies the location of the service");
qualfeat2.setHasLabel("Europe");
serv1.addQualFeature(qualfeat2);
qualfeat3.addType(CLOUDEnum.WINDOWS.getConceptURI());
qualfeat3.setComment("Feature that specifies the OS of the service");
qualfeat3.setHasLabel("Windows Server 2012 R2");
serv1.addQualFeature(qualfeat3);
//////////////////////////////////////////////////////////
- Quantitative Features Description
QuantitativeValue quantfeat1 = new QuantitativeValue();
QuantitativeValue quantfeat2 = new QuantitativeValue();
QuantitativeValue quantfeat3 = new QuantitativeValue();
quantfeat1.addType(CLOUDEnum.AVAILABILITY.getConceptURI());//feature type
quantfeat1.setValue(99);//quantitative value
quantfeat1.setUnitOfMeasurement("P1");//unit of measurement - P1
quantfeat1.setComment("Feature that specifies the availability of the service");//feature comment
serv1.addQuantFeature(quantfeat1);//link the feature to the service
quantfeat2.addType(CLOUDEnum.DISKSIZE.getConceptURI());
quantfeat2.setValue(400);
quantfeat1.setUnitOfMeasurement("E34");//unit of measurement - E34
quantfeat2.setComment("Feature that specifies the disk size of the service");
serv1.addQuantFeature(quantfeat2);
quantfeat3.addType(CLOUDEnum.MEMORYSIZE.getConceptURI());
quantfeat3.setValue(6);
quantfeat1.setUnitOfMeasurement("E34");//unit of measurement - E34
quantfeat3.setComment("Feature that specifies the RAM size of the service");
serv1.addQuantFeature(quantfeat3);
////////////////////////////////////////////////////////////////////////////////
With this, our Service description is complete! Now, we can proceed to step 2, creating the Service's PricePlan.
##### Step 2: Create an instance of the Offering class, link the created _Service_ and define its Price Plan