use of org.opentosca.toscana.core.plugin.PluginFileAccess.BufferedLineWriter in project TOSCAna by StuPro-TOSCAna.
the class ServiceHandler method addProviderServiceOfferings.
/**
* adds all offered services from the provider to an extra file
*/
private void addProviderServiceOfferings() throws IOException {
Provider provider = application.getProvider();
List<ServiceOffering> services = provider.getOfferedService();
BufferedLineWriter lineWriter = fileAccess.access(SERVICE_FILE_PATH);
logger.info("List all services from the provider to the file '{}'", SERVICE_FILE_PATH);
lineWriter.appendln("Following services you could choose:");
lineWriter.appendln(String.format("%-20s %-40s %-50s\n", "Name", " Plans", "Description"));
for (ServiceOffering service : services) {
String plans = "";
for (ServicePlan plan : service.getServicePlans()) {
String currentPlan;
if (plan.getFree()) {
currentPlan = plan.getName();
} else {
currentPlan = plan.getName() + "*";
}
plans = String.format("%s %s ", plans, currentPlan);
}
logger.debug("Add '{}' to the service list in file '{}'", service.getLabel(), SERVICE_FILE_PATH);
lineWriter.appendln(String.format("%-20s %-40s %-50s ", service.getLabel(), plans, service.getDescription()));
}
lineWriter.appendln("\n* These service plans have an associated cost. Creating a service instance will incur this cost.\n");
lineWriter.close();
}
Aggregations