You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cmda.apache.org by xi...@apache.org on 2015/09/09 00:49:48 UTC

[39/51] [partial] incubator-cmda git commit: Add frontend and backend

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/ClimateServiceController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/ClimateServiceController.java b/ApacheCMDA-Backend/app/controllers/ClimateServiceController.java
new file mode 100644
index 0000000..31702bb
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/ClimateServiceController.java
@@ -0,0 +1,490 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import models.*;
+import util.Common;
+import util.Constants;
+import play.mvc.*;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+/**
+ * The main set of web services.
+ */
+@Named
+@Singleton
+public class ClimateServiceController extends Controller {
+	private final int initialcount = 0;
+
+	// static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssz";
+	private final ClimateServiceRepository climateServiceRepository;
+	private final UserRepository userRepository;
+    private final ServiceEntryRepository serviceEntryRepository;
+
+	// We are using constructor injection to receive a repository to support our
+	// desire for immutability.
+	@Inject
+	public ClimateServiceController(
+			final ClimateServiceRepository climateServiceRepository,
+			UserRepository userRepository,ServiceEntryRepository serviceEntryRepository) {
+		this.climateServiceRepository = climateServiceRepository;
+		this.userRepository = userRepository;
+        this.serviceEntryRepository = serviceEntryRepository;
+	}
+
+	public Result addClimateService() {
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out
+					.println("Climate service not saved, expecting Json data");
+			return badRequest("Climate service not saved, expecting Json data");
+		}
+
+		// Parse JSON file
+		long rootServiceId = json.findPath("rootServiceId").asLong();
+		String creatorEmail = json.findPath("creatorEmail").asText();
+		String name = json.findPath("name").asText();
+		String purpose = json.findPath("purpose").asText();
+		String url = json.findPath("url").asText();
+		String scenario = json.findPath("scenario").asText();
+		Date createTime = new Date();
+		SimpleDateFormat format = new SimpleDateFormat(Common.DATE_PATTERN);
+		try {
+			createTime = format.parse(json.findPath("createTime").asText());
+		} catch (ParseException e) {
+			System.out
+					.println("No creation date specified, set to current time");
+		}
+		String versionNo = json.findPath("versionNo").asText();
+
+		try {
+			User user = userRepository.findByEmail(creatorEmail);
+			ClimateService climateService = new ClimateService(rootServiceId,
+					user, name, purpose, url, scenario, createTime, versionNo);
+			ClimateService savedClimateService = climateServiceRepository
+					.save(climateService);
+			String registerNote = "ClimateService Name: " + savedClimateService.getName() + ", VersionNo: "+versionNo;
+			ServiceEntry serviceEntry = new ServiceEntry(createTime, versionNo, user, createTime, registerNote, initialcount, savedClimateService);
+			serviceEntryRepository.save(serviceEntry);
+			System.out.println("Climate Service saved: "
+					+ savedClimateService.getName());
+			return created(new Gson().toJson(savedClimateService.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Climate Service not saved: " + name);
+			return badRequest("Climate Service not saved: " + name);
+		}
+	}
+	
+	public Result savePage() {
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out.println("Climate service not saved, expecting Json data");
+			return badRequest("Climate service not saved, expecting Json data");
+		}
+
+		// Parse JSON file
+		String temp = json.findPath("pageString").asText();
+
+		// Remove delete button from preview page
+		String result = temp.replaceAll("<td><button type=\\\\\"button\\\\\" class=\\\\\"btn btn-danger\\\\\" onclick=\\\\\"Javascript:deleteRow\\(this\\)\\\\\">delete</button></td>", "");	
+		
+		result = StringEscapeUtils.unescapeJava(result);
+		result = result.substring(1, result.length() - 1);
+		System.out.println(result);
+		
+		String str1 = Constants.htmlHead;
+		String str2 = Constants.htmlTail;
+		
+		result = str1 + result + str2;
+		
+		String timeStamp = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss")
+				.format(new Date());
+		String location = "climateServicePageRepository/" + timeStamp + ".txt";
+
+		File theDir = new File("climateServicePageRepository");
+
+		// if the directory does not exist, create it
+		if (!theDir.exists()) {
+			System.out.println("creating directory: climateServicePageRepository");
+			boolean create = false;
+
+			try {
+				theDir.mkdir();
+				create = true;
+			} catch (SecurityException se) {
+				// handle it
+			}
+			if (create) {
+				System.out.println("DIR created");
+			}
+		} else {
+			System.out.println("No");
+		}
+
+		try {
+			File file = new File(location);
+			BufferedWriter output = new BufferedWriter(new FileWriter(file));
+			output.write(result);
+			output.close();
+		} catch (FileNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return ok(result);
+	}
+
+	public Result deleteClimateServiceById(long id) {
+		ClimateService climateService = climateServiceRepository.findOne(id);
+		if (climateService == null) {
+			System.out.println("Climate service not found with id: " + id);
+			return notFound("Climate service not found with id: " + id);
+		}
+
+		climateServiceRepository.delete(climateService);
+		System.out.println("Climate service is deleted: " + id);
+		return ok("Climate service is deleted: " + id);
+	}
+	
+	public Result deleteClimateServiceByName(String name) {
+		ClimateService climateService = climateServiceRepository.findFirstByName(name);
+		if (climateService == null) {
+			System.out.println("Climate service not found with name: " + name);
+			return notFound("Climate service not found with name: " + name);
+		}
+
+		climateServiceRepository.delete(climateService);
+		System.out.println("Climate service is deleted: " + name);
+		return ok("Climate service is deleted: " + name);
+	}
+
+	public Result updateClimateServiceById(long id) {
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out
+					.println("Climate service not saved, expecting Json data");
+			return badRequest("Climate service not saved, expecting Json data");
+		}
+
+		// Parse JSON file
+		long rootServiceId = json.findPath("rootServiceId").asLong();
+		long creatorId = json.findPath("creatorId").asLong();
+		String name = json.findPath("name").asText();
+		String purpose = json.findPath("purpose").asText();
+		String url = json.findPath("url").asText();
+		String scenario = json.findPath("scenario").asText();
+		String versionNo = json.findPath("versionNo").asText();
+		// Creation time should be immutable and not updated.
+
+		try {
+			ClimateService climateService = climateServiceRepository
+					.findOne(id);
+			User user = userRepository.findOne(creatorId);
+			ServiceEntry serviceEntry = null;
+			if (versionNo.equals(climateService.getVersionNo())) {
+				List<ServiceEntry> serviceEntries = serviceEntryRepository.findByClimateServiceAndVersionNo(climateService, versionNo);
+				if (serviceEntries.size()==0) {
+					String registerNote = "ClimateService Name: " + climateService.getName() + ", VersionNo: "+versionNo;
+					serviceEntry = new ServiceEntry(climateService.getCreateTime(), versionNo, user, climateService.getCreateTime(), registerNote, initialcount, climateService);
+				}
+				else {
+					serviceEntry = serviceEntries.get(0);
+				}
+			}
+			else {
+				String registerNote = "ClimateService Name:" + climateService.getName() + ", VersionNo: "+versionNo;
+				serviceEntry = new ServiceEntry(climateService.getCreateTime(), versionNo, user, climateService.getCreateTime(), registerNote, initialcount, climateService);
+			}
+			climateService.setUser(user);
+			climateService.setName(name);
+			climateService.setPurpose(purpose);
+			climateService.setRootServiceId(rootServiceId);
+			climateService.setScenario(scenario);
+			climateService.setUrl(url);
+			climateService.setVersionNo(versionNo);
+			ClimateService savedClimateService = climateServiceRepository
+					.save(climateService);
+			serviceEntry.setClimateService(savedClimateService);
+			ServiceEntry savedServiceEntry = serviceEntryRepository.save(serviceEntry);
+			
+			System.out.println("Climate Service updated: "
+					+ savedClimateService.getName());
+			return created("Climate Service updated: "
+					+ savedClimateService.getName());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Climate Service not updated: " + name);
+			return badRequest("Climate Service not updated: " + name);
+		}
+	}
+
+	public Result updateClimateServiceByName(String oldName) {
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out
+					.println("Climate service not saved, expecting Json data");
+			return badRequest("Climate service not saved, expecting Json data");
+		}
+		System.out.println(json);
+		// Parse JSON file
+		long rootServiceId = json.findPath("rootServiceId").asLong();
+		long creatorId = json.findPath("creatorId").asLong();
+		String name = json.findPath("name").asText();
+		String purpose = json.findPath("purpose").asText();
+		String url = json.findPath("url").asText();
+		String scenario = json.findPath("scenario").asText();
+		String versionNo = json.findPath("versionNo").asText();
+		// Creation time is immutable and should not be updated
+
+		if (oldName == null || oldName.length() == 0) {
+			System.out.println("Old climate Service Name is null or empty!");
+			return badRequest("Old climate Service Name is null or empty!");
+		}
+
+		try {
+			ClimateService climateService = climateServiceRepository
+					.findFirstByName(oldName);
+			User user = userRepository.findOne(creatorId);
+			ServiceEntry serviceEntry = null;
+			if (versionNo.equals(climateService.getVersionNo())) {
+				List<ServiceEntry> serviceEntries = serviceEntryRepository.findByClimateServiceAndVersionNo(climateService, versionNo);
+				if (serviceEntries.size()==0) {
+					String registerNote = "ClimateService Name: " + climateService.getName() + ", VersionNo: "+versionNo;
+					serviceEntry = new ServiceEntry(climateService.getCreateTime(), versionNo, user, climateService.getCreateTime(), registerNote, initialcount, climateService);
+				}
+				else {
+					serviceEntry = serviceEntries.get(0);
+				}
+			}
+			else {
+				String registerNote = "ClimateService Name: " + climateService.getName() + ", VersionNo: "+versionNo;
+				serviceEntry = new ServiceEntry(climateService.getCreateTime(), versionNo, user, climateService.getCreateTime(), registerNote, initialcount, climateService);
+			}
+			climateService.setName(name);
+			climateService.setPurpose(purpose);
+			climateService.setRootServiceId(rootServiceId);
+			climateService.setScenario(scenario);
+			climateService.setUrl(url);
+			
+			climateService.setUser(user);
+			climateService.setVersionNo(versionNo);
+
+			ClimateService savedClimateService = climateServiceRepository
+					.save(climateService);
+			serviceEntry.setClimateService(savedClimateService);
+			ServiceEntry savedServiceEntry = serviceEntryRepository.save(serviceEntry);
+			System.out.println("Climate Service updated: "
+					+ savedClimateService.getName());
+			return created("Climate Service updated: "
+					+ savedClimateService.getName());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Climate Service not updated: " + name);
+			return badRequest("Climate Service not updated: " + name);
+		}
+	}
+
+	public Result getClimateService(String name, String format) {
+		if (name == null || name.length() == 0) {
+			System.out.println("Climate Service Name is null or empty!");
+			return badRequest("Climate Service Name is null or empty!");
+		}
+
+		List<ClimateService> climateService = climateServiceRepository
+				.findAllByName(name);
+		if (climateService == null) {
+			System.out.println("Climate service not found with name: " + name);
+			return notFound("Climate service not found with name: " + name);
+		}
+
+		String result = new String();
+		if (format.equals("json")) {
+			result = new Gson().toJson(climateService);
+		}
+
+		return ok(result);
+	}
+
+	public Result getClimateServiceById(long id) {
+		ClimateService climateService = climateServiceRepository.findOne(id);
+		if (climateService == null) {
+			System.out.println("Climate service not found with id: " + id);
+			return notFound("Climate service not found with id: " + id);
+		}
+
+		String result = new Gson().toJson(climateService);
+
+		return ok(result);
+	}
+
+	public Result getAllClimateServices(String format) {
+		Iterable<ClimateService> climateServices = climateServiceRepository
+				.findAll();
+		if (climateServices == null) {
+			System.out.println("No climate service found");
+		}
+
+		String result = new String();
+		if (format.equals("json")) {
+			result = new Gson().toJson(climateServices);
+		}
+
+		return ok(result);
+
+	}
+
+    public Result getAllClimateServicesOrderByCreateTime(String format){
+        Iterable<ClimateService> climateServices = climateServiceRepository
+                .findByOrderByCreateTimeDesc();
+        if (climateServices == null) {
+            System.out.println("No climate service found");
+        }
+
+        String result = new String();
+        if (format.equals("json")) {
+            result = new Gson().toJson(climateServices);
+        }
+
+        return ok(result);
+    }
+
+    public Result getAllClimateServicesOrderByLatestAccessTime(String format){
+        Iterable<ClimateService> climateServices = climateServiceRepository.getClimateServiceOrderByLatestAccessTime();
+        if (climateServices == null) {
+            System.out.println("No climate service found");
+        }
+
+        String result = new String();
+        if (format.equals("json")) {
+            result = new Gson().toJson(climateServices);
+        }
+
+        return ok(result);
+    }
+
+    public Result getAllClimateServicesOrderByCount(String format){
+//        Iterable<ClimateService> climateServices = climateServiceRepository
+//                .findByOrderByCreateTimeDesc();
+        Iterable<ClimateService> climateServices = climateServiceRepository.getClimateServiceOrderByCount();
+        if (climateServices == null) {
+            System.out.println("No climate service found");
+        }
+
+        String result = new String();
+        if (format.equals("json")) {
+            result = new Gson().toJson(climateServices);
+        }
+
+        return ok(result);
+    }
+
+    public Result addServiceEntry() {
+        JsonNode json = request().body().asJson();
+        if (json == null) {
+            System.out
+                    .println("Climate service not saved, expecting Json data");
+            return badRequest("Climate service not saved, expecting Json data");
+        }
+
+        // Parse JSON file
+        String versionNo = json.findPath("versionNo").asText();
+        String registerNote = json.findPath("registerNote").asText();
+        int count = json.findPath("count").asInt();
+        // String scenario = json.findPath("scenario").asText();
+        long serviceId = json.findPath("serviceId").asLong();
+        long creatorId = json.findPath("creatorId").asLong();
+
+        Date registerTime = new Date();
+        SimpleDateFormat format = new SimpleDateFormat(Common.DATE_PATTERN);
+        try {
+            registerTime = format.parse(json.findPath("registerTimeStamp").asText());
+        } catch (ParseException e) {
+            System.out
+                    .println("No creation date specified, set to current time");
+        }
+
+        Date latestAccessTime = new Date();
+        try {
+            latestAccessTime = format.parse(json.findPath("latestAccessTimeStamp").asText());
+        } catch (ParseException e) {
+            System.out
+                    .println("No creation date specified, set to current time");
+        }
+
+        try {
+            ClimateService climateService = climateServiceRepository.findOne(serviceId);
+            User creator = userRepository.findOne(creatorId);
+            ServiceEntry entry = new ServiceEntry();
+            entry.setClimateService(climateService);
+            entry.setCount(count);
+            entry.setRegisterNote(registerNote);
+            entry.setVersionNo(versionNo);
+            entry.setUser(creator);
+            entry.setRegisterTimeStamp(registerTime);
+            entry.setLatestAccessTimestamp(latestAccessTime);
+
+            ServiceEntry savedServiceEntry = serviceEntryRepository.save(entry);
+
+            System.out.println("Service Entry saved: "
+                    + savedServiceEntry.getId());
+            return created(new Gson().toJson(savedServiceEntry));
+        } catch (PersistenceException pe) {
+            pe.printStackTrace();
+            System.out.println("Service Entry not saved: " + serviceId);
+            return badRequest("Service Entry not saved: " + serviceId);
+        }
+    }
+
+    public Result getAllServiceEntries(String format) {
+        Iterable<ServiceEntry> serviceEntries = serviceEntryRepository
+                .findAll();
+        if (serviceEntries == null) {
+            System.out.println("No service entry found");
+        }
+
+        String result = new String();
+        if (format.equals("json")) {
+            result = new Gson().toJson(serviceEntries);
+        }
+
+        return ok(result);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/ConferencePublicationController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/ConferencePublicationController.java b/ApacheCMDA-Backend/app/controllers/ConferencePublicationController.java
new file mode 100644
index 0000000..e189097
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/ConferencePublicationController.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+import models.ConferencePublication;
+import models.ConferencePublicationRepository;
+import models.User;
+import models.UserRepository;
+import play.mvc.Controller;
+import play.mvc.Result;
+
+/**
+ * The main set of web services.
+ */
+@Named
+@Singleton
+public class ConferencePublicationController extends Controller {
+	private final ConferencePublicationRepository ConferencePublicationRepository;
+    private final UserRepository userRepository;
+	
+	// We are using constructor injection to receive a repository to support our desire for immutability.
+    @Inject
+    public ConferencePublicationController(final ConferencePublicationRepository ConferencePublicationRepository,
+    		final UserRepository userRepository) {
+        this.ConferencePublicationRepository = ConferencePublicationRepository;
+        this.userRepository = userRepository;
+    }
+    
+    public Result addConferencePublication() {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("ConferencePublication not saved, expecting Json data");
+			return badRequest("ConferencePublication not saved, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	String paperTitle = json.findPath("paperTitle").asText();
+    	long authorId = json.findPath("authorId").asLong();
+		String publicationChannel = json.findPath("publicationChannel").asText();
+		int year = json.findPath("year").asInt();
+		String name = json.findPath("name").asText();
+    	String location = json.findPath("location").asText();
+		String time = json.findPath("time").asText();
+		String page = json.findPath("page").asText();
+		
+		try {
+			User author = userRepository.findOne(authorId);
+			ConferencePublication ConferencePublication = new ConferencePublication(paperTitle, author, publicationChannel,
+					year, name, location, time, page);
+			ConferencePublication savedConferencePublication = ConferencePublicationRepository.save(ConferencePublication);
+			
+			System.out.println("ConferencePublication saved: " + savedConferencePublication.getName());
+			return created(new Gson().toJson(savedConferencePublication.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println(pe.getClass().toString());
+			System.out.println("ConferencePublication not saved: " + name);
+			return badRequest("ConferencePublication not saved: " + name);
+		}			
+    }
+    
+    public Result deleteConferencePublication(Long id) {
+    	ConferencePublication ConferencePublication = ConferencePublicationRepository.findOne(id);
+    	if (ConferencePublication == null) {
+    		System.out.println("ConferencePublication not found with id: " + id);
+			return notFound("ConferencePublication not found with id: " + id);
+    	}
+    	
+    	ConferencePublicationRepository.delete(ConferencePublication);
+    	System.out.println("ConferencePublication is deleted: " + id);
+		return ok("ConferencePublication is deleted: " + id);
+    }
+    
+    public Result updateConferencePublication(long id) {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("ConferencePublication not updated, expecting Json data");
+			return badRequest("ConferencePublication not updated, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	String paperTitle = json.findPath("paperTitle").asText();
+    	long authorId = json.findPath("authorId").asLong();
+		String publicationChannel = json.findPath("publicationChannel").asText();
+		int year = json.findPath("year").asInt();
+		String name = json.findPath("name").asText();
+    	String location = json.findPath("location").asText();
+		String time = json.findPath("time").asText();
+		String page = json.findPath("page").asText();
+		
+		try {
+			User author = userRepository.findOne(authorId);
+			
+			ConferencePublication ConferencePublication = ConferencePublicationRepository.findOne(id);
+			ConferencePublication.setPaperTitle(paperTitle);
+			ConferencePublication.setAuthor(author);
+			ConferencePublication.setPublicationChannel(publicationChannel);
+			ConferencePublication.setYear(year);
+			ConferencePublication.setName(name);
+			ConferencePublication.setLocation(location);
+			ConferencePublication.setTime(time);
+			ConferencePublication.setPage(page);
+			
+			ConferencePublication savedConferencePublication = ConferencePublicationRepository.save(ConferencePublication);
+			
+			System.out.println("ConferencePublication updated: " + savedConferencePublication.getName());
+			return created("ConferencePublication updated: " + savedConferencePublication.getName());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("ConferencePublication not updated: " + id);
+			return badRequest("ConferencePublication not updated: " + id);
+		}			
+    }
+    
+    public Result getConferencePublication(Long id, String format) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	
+    	ConferencePublication ConferencePublication = ConferencePublicationRepository.findOne(id);
+    	if (ConferencePublication == null) {
+    		System.out.println("ConferencePublication not found with id: " + id);
+			return notFound("ConferencePublication not found with id: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(ConferencePublication);
+    	}
+    	
+    	return ok(result);
+    }
+    
+    public Result getAllConferencePublications(String format) {
+    	
+    	String result = new String();
+    	
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(ConferencePublicationRepository.findAll());
+    	}
+    			
+    	return ok(result);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/DatasetController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/DatasetController.java b/ApacheCMDA-Backend/app/controllers/DatasetController.java
new file mode 100644
index 0000000..30e06c7
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/DatasetController.java
@@ -0,0 +1,314 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+import models.ClimateService;
+import models.ClimateServiceRepository;
+import models.Dataset;
+import models.DatasetEntryRepository;
+import models.DatasetRepository;
+import models.Instrument;
+import models.InstrumentRepository;
+import play.mvc.*;
+
+@Named
+@Singleton
+public class DatasetController extends Controller {
+	public static final String WILDCARD = "%";
+	
+	private final ClimateServiceRepository climateServiceRepository;
+	private final InstrumentRepository instrumentRepository;
+	private final DatasetRepository datasetRepository;
+	private final DatasetEntryRepository datasetEntryRepository;
+	
+	@Inject
+	public DatasetController(ClimateServiceRepository climateServiceRepository, InstrumentRepository instrumentRepository, DatasetRepository datasetRepository, DatasetEntryRepository datasetEntryRepository) {
+		this.climateServiceRepository = climateServiceRepository;
+		this.instrumentRepository = instrumentRepository;
+		this.datasetRepository = datasetRepository;
+		this.datasetEntryRepository = datasetEntryRepository;
+	}
+	
+	public Result addDataset() {
+		JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Dataset not saved, expecting Json data");
+			return badRequest("Dataset not saved, expecting Json data");
+    	}
+    	String name = json.findPath("name").asText();
+    	String agencyId = json.findPath("agencyId").asText();
+    	long instrumentId = json.findPath("instrumentId").asLong();
+    	String url = json.findPath("url").asText();
+    	long publishTimeStampNumber = json.findPath("publishTimeStamp").asLong();
+    	
+    	long startTimeNumber = json.findPath("dataSetStartTime").asLong();
+    	long endTimeNumber = json.findPath("dataSetEndTime").asLong();
+    	
+    	String physicalVariable = json.findPath("physicalVariable").asText();
+    	String CMIP5VarName = json.findPath("CMIP5VarName").asText();
+    	String units = json.findPath("units").asText();
+    	String gridDimension = json.findPath("gridDimension").asText();
+    	String status = json.findPath("status").asText();
+    	String responsiblePerson = json.findPath("responsiblePerson").asText();
+    	String variableNameInWebInterface = json.findPath("variableNameInWebInterface").asText();
+    	String dataSourceInputParameterToCallScienceApplicationCode = json.findPath("dataSourceInputParameterToCallScienceApplicationCode").asText();
+    	String variableNameInputParameterToCallScienceApplicationCode = json.findPath("variableNameInputParameterToCallScienceApplicationCode").asText();
+    	String dataSourceNameinWebInterface = json.findPath("dataSourceNameinWebInterface").asText();
+    	String comment  = json.findPath("comment").asText();
+    	Date publishTimeStamp = new Date(publishTimeStampNumber);
+    	
+    	Date startTime = new Date(startTimeNumber);
+    	Date endTime = new Date(endTimeNumber);
+    	
+    	JsonNode ClimateServices = json.findPath("ServiesId");
+    	List<Long> climateServicesId = new ArrayList<Long>();
+    	for(int i = 0; i < ClimateServices.size(); i++) {
+    		climateServicesId.add(ClimateServices.get(i).asLong());
+    	}
+    	try {
+			Instrument instrument = instrumentRepository.findOne(instrumentId);
+			List<ClimateService>climateServiceSet = new ArrayList<ClimateService>();
+			for(int i=0;i<climateServicesId.size();i++) {
+				climateServiceSet.add(climateServiceRepository.findOne(climateServicesId.get(i)));
+			}
+			Dataset dataset = new Dataset(name, dataSourceNameinWebInterface, agencyId, instrument, climateServiceSet, publishTimeStamp, url, physicalVariable, CMIP5VarName, units, gridDimension, dataSourceNameinWebInterface, status, responsiblePerson, variableNameInWebInterface, dataSourceInputParameterToCallScienceApplicationCode, variableNameInputParameterToCallScienceApplicationCode, comment, startTime, endTime);
+			Dataset savedServiceConfiguration = datasetRepository.save(dataset);
+			System.out.println("Dataset saved: "+ savedServiceConfiguration.getId());
+			return created(new Gson().toJson(dataset.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Dataset not created");
+			return badRequest("Dataset not created");
+		}
+    	
+	}
+	
+    public Result updateDatasetById(long id) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out.println("Dataset not saved, expecting Json data");
+			return badRequest("Dataset Configuration not saved, expecting Json data");
+		}
+		String name = json.findPath("name").asText();
+    	String agencyId = json.findPath("agencyId").asText();
+    	long instrumentId = json.findPath("instrumentId").asLong();
+    	String url = json.findPath("url").asText();
+    	long publishTimeStampNumber = json.findPath("publishTimeStamp").asLong();
+    	
+    	long startTimeNumber = json.findPath("dataSetStartTime").asLong();
+    	long endTimeNumber = json.findPath("dataSetEndTime").asLong();
+    	
+    	String physicalVariable = json.findPath("physicalVariable").asText();
+    	String CMIP5VarName = json.findPath("CMIP5VarName").asText();
+    	String units = json.findPath("units").asText();
+    	String gridDimension = json.findPath("gridDimension").asText();
+    	String source = json.findPath("source").asText();
+    	String status = json.findPath("status").asText();
+    	String responsiblePerson = json.findPath("responsiblePerson").asText();
+    	String variableNameInWebInterface = json.findPath("variableNameInWebInterface").asText();
+    	String dataSourceInputParameterToCallScienceApplicationCode = json.findPath("dataSourceInputParameterToCallScienceApplicationCode").asText();
+    	String variableNameInputParameterToCallScienceApplicationCode = json.findPath("variableNameInputParameterToCallScienceApplicationCode").asText();
+    	String dataSourceNameinWebInterface = json.findPath("dataSourceNameinWebInterface").asText();
+    	String comment  = json.findPath("comment").asText();
+    	Date publishTimeStamp = new Date(publishTimeStampNumber);
+    	
+    	Date startTime = new Date(startTimeNumber);
+    	Date endTime = new Date(endTimeNumber);
+    	
+    	JsonNode ClimateServices = json.findPath("ServiesId");
+    	List<Long> climateServicesId = new ArrayList<Long>();
+    	for(int i = 0; i < ClimateServices.size(); i++) {
+    		climateServicesId.add(ClimateServices.get(i).asLong());
+    	}
+	
+		try {
+			Dataset dataset = datasetRepository.findOne(id);
+			
+			dataset.setName(name);
+			dataset.setComment(comment);
+			dataset.setDataSourceNameinWebInterface(dataSourceNameinWebInterface);
+			dataset.setAgencyId(agencyId);
+			Instrument instrument = instrumentRepository.findOne(instrumentId);
+			dataset.setInstrument(instrument);
+			dataset.setUrl(url);
+			dataset.setPublishTimeStamp(publishTimeStamp);
+			
+			dataset.setStartTime(startTime);
+			dataset.setEndTime(endTime);
+			
+			dataset.setPhysicalVariable(physicalVariable);
+			dataset.setCMIP5VarName(CMIP5VarName);
+			dataset.setUnits(units);
+			dataset.setGridDimension(gridDimension);
+			dataset.setSource(source);
+			dataset.setStatus(status);
+			dataset.setResponsiblePerson(responsiblePerson);
+			dataset.setVariableNameInputParameterToCallScienceApplicationCode(variableNameInputParameterToCallScienceApplicationCode);
+			dataset.setDataSourceInputParameterToCallScienceApplicationCode(dataSourceInputParameterToCallScienceApplicationCode);
+			dataset.setVariableNameInWebInterface(variableNameInWebInterface);
+			List<ClimateService>climateServiceSet = new ArrayList<ClimateService>();
+			for(int i=0;i<climateServicesId.size();i++) {
+				climateServiceSet.add(climateServiceRepository.findOne(climateServicesId.get(i)));
+			}
+			dataset.setClimateServiceSet(climateServiceSet);
+			Dataset savedDataset = datasetRepository.save(dataset);
+			System.out.println("Dataset updated: "+ savedDataset.getId());
+			return created("Dataset updated: "+ savedDataset.getId());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Dataset not saved: "+id);
+			return badRequest("Dataset not saved: "+id);
+		}			
+    }
+
+	
+    public Result deleteDataset(long id) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	Dataset dataset = datasetRepository.findOne(id);
+    	if (dataset == null) {
+    		System.out.println("Dataset not found with id: " + id);
+			return notFound("Dataset not found with id: " + id);
+    	}
+    	datasetRepository.delete(dataset);
+    	System.out.println("Dataset is deleted: " + id);
+		return ok("Dataset is deleted: " + id);
+    }
+    public Result getDataset(long id, String format) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	Dataset dataset = datasetRepository.findOne(id);
+    	if (dataset == null) {
+    		System.out.println("Dataset not found with name: " + id);
+			return notFound("Dataset not found with name: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(dataset);
+    	}
+    	
+    	return ok(result);
+    }
+    
+    public Result queryDatasets() {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Datasets cannot be queried, expecting Json data");
+    		return badRequest("Datasets cannot be queried, expecting Json data");
+    	}
+    	String result = new String();
+    	try {
+    		//Parse JSON file
+    		String name = json.path("name").asText();
+    		if (name.isEmpty()) {
+    			name = WILDCARD;
+    		}
+    		else {
+    			name = WILDCARD+name+WILDCARD;
+    		}
+    		String agencyId = json.path("agencyId").asText();
+    		if (agencyId.isEmpty()) {
+    			agencyId = WILDCARD;
+    		}
+    		else {
+    			agencyId = WILDCARD+agencyId+WILDCARD;
+    		}
+    		String gridDimension = json.path("gridDimension").asText();
+    		if (gridDimension.isEmpty()) {
+    			gridDimension = WILDCARD;
+    		}
+    		else {
+    			gridDimension = WILDCARD+gridDimension+WILDCARD;
+    		}
+    		String physicalVariable = json.path("physicalVariable").asText();
+    		if (physicalVariable.isEmpty()) {
+    			physicalVariable = WILDCARD;
+    		}
+    		else {
+    			physicalVariable = WILDCARD+physicalVariable+WILDCARD;
+    		}
+    		
+    		Date startTime = new Date(0);
+			Date endTime = new Date();
+			long startTimeNumber = json.findPath("dataSetStartTime").asLong();
+			long endTimeNumber = json.findPath("dataSetEndTime").asLong();
+    		
+			if (startTimeNumber >= 0 ) {
+				startTime = new Date(startTimeNumber);
+			}
+			if (endTimeNumber >= 0) {
+				endTime = new Date(endTimeNumber);
+			}
+			
+			String source = json.path("instrument").asText();
+			if (source.isEmpty()) {
+				source = WILDCARD;
+    		}
+			else {
+				source = WILDCARD+source+WILDCARD;
+			}
+    		
+    		List<Dataset> datasets;
+    		if (source.isEmpty()) {
+    			datasets = datasetRepository.findDataset(name, agencyId, gridDimension, physicalVariable, startTime, endTime);
+    					
+    		} else {
+    			datasets = datasetRepository.findDatasetWithInstrument(name, agencyId, gridDimension, physicalVariable, source, startTime, endTime);
+    		}
+    		result = new Gson().toJson(datasets);
+    	} catch (Exception e) {
+    		System.out.println("ServiceExecutionLog cannot be queried, query is corrupt");
+    		return badRequest("ServiceExecutionLog cannot be queried, query is corrupt");
+    	}
+
+    	return ok(result);
+    }
+
+    
+    public Result getAllDatasets(String format) {
+    	try {
+    		Iterable<Dataset>datasets =  datasetRepository.findAll();
+    		String result = new String();
+    		result = new Gson().toJson(datasets);
+    		return ok(result);
+    	} catch (Exception e) {
+    		return badRequest("Dataset not found");
+    	}
+    }
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/DatasetLogController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/DatasetLogController.java b/ApacheCMDA-Backend/app/controllers/DatasetLogController.java
new file mode 100644
index 0000000..36d5a23
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/DatasetLogController.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+import models.Dataset;
+import models.DatasetLog;
+import models.DatasetLogRepository;
+import models.DatasetRepository;
+import models.ServiceExecutionLog;
+import models.ServiceExecutionLogRepository;
+import play.mvc.*;
+
+@Named
+@Singleton
+public class DatasetLogController extends Controller {
+	
+	private final DatasetLogRepository datasetLogRepository;
+	private final DatasetRepository datasetRepository;
+	private final ServiceExecutionLogRepository serviceExecutionLogRepository;
+	
+	@Inject
+	public DatasetLogController(DatasetRepository datasetRepository, 
+			DatasetLogRepository datasetLogRepository,
+			ServiceExecutionLogRepository serviceExecutionLogRepository) {
+		this.datasetLogRepository = datasetLogRepository;
+		this.datasetRepository = datasetRepository;
+		this.serviceExecutionLogRepository = serviceExecutionLogRepository;
+	}
+	
+	public Result addDatasetLog() {
+		JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("DatasetLog not saved, expecting Json data");
+			return badRequest("DatasetLog not saved, expecting Json data");
+    	}
+    	
+    	String plotUrl = json.findPath("plotUrl").asText();
+    	String dataUrl = json.findPath("dataUrl").asText();
+    	long originalDatasetId = json.findPath("originalDatasetId").asLong();
+    	long outputDatasetId = json.findPath("outputDatasetId").asLong();
+    	long serviceExecutionLogId = json.findPath("serviceExecutionLogId").asLong();
+    	long datasetId = json.findPath("datasetId").asLong();
+    	
+    	try {
+			Dataset originalDataset = datasetRepository.findOne(originalDatasetId);
+			Dataset outputDataset = datasetRepository.findOne(outputDatasetId);
+			Dataset dataset = datasetRepository.findOne(datasetId);
+			ServiceExecutionLog serviceExecutionLog = serviceExecutionLogRepository.findOne(serviceExecutionLogId);
+			DatasetLog datasetLog = new DatasetLog(serviceExecutionLog, dataset, plotUrl, dataUrl, originalDataset, outputDataset);
+			DatasetLog saveddatasetLog = datasetLogRepository.save(datasetLog);
+			System.out.println("DatasetLog saved: "+ saveddatasetLog.getId());
+			return created(new Gson().toJson(datasetLog.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("DatasetLog not created");
+			return badRequest("DatasetLog Configuration not created");
+		}
+    	
+	}
+	
+    public Result updateDatasetLogById(long id) {
+	    JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out.println("DatasetLog not saved, expecting Json data");
+			return badRequest("DatasetLog Configuration not saved, expecting Json data");
+		}
+		
+    	String plotUrl = json.findPath("plotUrl").asText();
+    	String dataUrl = json.findPath("dataUrl").asText();
+    	long originalDatasetId = json.findPath("originalDatasetId").asLong();
+    	long outputDatasetId = json.findPath("outputDatasetId").asLong();
+    	long serviceExecutionLogId = json.findPath("serviceExecutionLogId").asLong();
+    	long datasetId = json.findPath("datasetId").asLong();
+
+		try {
+			Dataset originalDataset = datasetRepository.findOne(originalDatasetId);
+			Dataset outputDataset = datasetRepository.findOne(outputDatasetId);
+			Dataset dataset = datasetRepository.findOne(datasetId);
+			ServiceExecutionLog serviceExecutionLog = serviceExecutionLogRepository.findOne(serviceExecutionLogId);
+			DatasetLog datasetLog = datasetLogRepository.findOne(id);
+			datasetLog.setDataSet(dataset);
+			datasetLog.setDataUrl(dataUrl);
+			datasetLog.setOriginalDataset(originalDataset);
+			datasetLog.setOutputDataset(outputDataset);
+			datasetLog.setPlotUrl(plotUrl);
+			datasetLog.setServiceExecutionLog(serviceExecutionLog);
+			DatasetLog savedDatasetLog = datasetLogRepository.save(datasetLog);
+			
+			System.out.println("DatasetLog updated: "+ savedDatasetLog.getId());
+			return created("DatasetLog updated: "+ savedDatasetLog.getId());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("DatasetLog not saved: "+id);
+			return badRequest("DatasetLog not saved: "+id);
+		}			
+    }
+
+	
+    public Result deleteDatasetLog(long id) {
+    	DatasetLog datasetLog = datasetLogRepository.findOne(id);
+    	if (datasetLog == null) {
+    		System.out.println("DatasetLog not found with id: " + id);
+			return notFound("DatasetLog not found with id: " + id);
+    	}
+    	
+    	datasetLogRepository.delete(datasetLog);
+    	System.out.println("DatasetLog is deleted: " + id);
+		return ok("DatasetLog is deleted: " + id);
+    }
+    
+    public Result getDatasetLog(long id, String format) {
+    	DatasetLog datasetLog = datasetLogRepository.findOne(id);
+    	if (datasetLog == null) {
+    		System.out.println("DatasetLog not found with name: " + id);
+			return notFound("DatasetLog not found with name: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(datasetLog);
+    	}
+    	
+    	return ok(result);
+    }
+
+    public Result getAllDatasetLogs(String format) {
+    	try {
+    		Iterable<DatasetLog>datasetLogs =  datasetLogRepository.findAll();
+    		String result = new String();
+    		result = new Gson().toJson(datasetLogs);
+    		return ok(result);
+    	} catch (Exception e) {
+    		return badRequest("DatasetLog not found");
+    	}
+    }
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/InstrumentController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/InstrumentController.java b/ApacheCMDA-Backend/app/controllers/InstrumentController.java
new file mode 100644
index 0000000..d4945ba
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/InstrumentController.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import java.util.Date;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+import models.Instrument;
+import models.InstrumentRepository;
+import play.mvc.*;
+
+@Named
+@Singleton
+public class InstrumentController extends Controller {
+	
+	private final InstrumentRepository instrumentRepository;
+	
+	@Inject
+	public InstrumentController(InstrumentRepository instrumentRepository) {
+		this.instrumentRepository = instrumentRepository;
+	}
+	
+	public Result addInstrument() {
+		JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Instrument not saved, expecting Json data");
+			return badRequest("Instrument not saved, expecting Json data");
+    	}
+    	String name = json.findPath("name").asText();
+    	String description = json.findPath("description").asText();
+    	long launchDateNumber = json.findPath("launchDate").asLong();
+    	Date launchDate = new Date(launchDateNumber);
+    	try {
+			Instrument instrument = new Instrument(name, description,launchDate);
+			Instrument savedinstrument = instrumentRepository.save(instrument);
+			System.out.println("Instrument saved: "+ savedinstrument.getId());
+			return created(new Gson().toJson(instrument.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Instrument not created");
+			return badRequest("Instrument Configuration not created");
+		}
+    	
+	}
+	
+    public Result updateInstrumentById(long id) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+	    JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out.println("Instrument not saved, expecting Json data");
+			return badRequest("Instrument Configuration not saved, expecting Json data");
+		}
+		long instrumentId = json.findPath("id").asLong();
+		String name = json.findPath("name").asText();
+    	String description = json.findPath("description").asText();
+    	long launchDateNumber = json.findPath("launchDate").asLong();
+    	Date launchDate = new Date(launchDateNumber);
+		try {
+			Instrument instrument = instrumentRepository.findOne(instrumentId);
+			instrument.setDescription(description);
+			instrument.setLaunchDate(launchDate);
+			instrument.setName(name);
+			Instrument savedInstrument = instrumentRepository.save(instrument);
+			
+			System.out.println("Instrument updated: "+ savedInstrument.getId());
+			return created("Instrument updated: "+ savedInstrument.getId());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Instrument not saved: "+id);
+			return badRequest("Instrument not saved: "+id);
+		}			
+    }
+
+	
+    public Result deleteInstrument(long id) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	Instrument instrument = instrumentRepository.findOne(id);
+    	if (instrument == null) {
+    		System.out.println("Instrument not found with id: " + id);
+			return notFound("Instrument not found with id: " + id);
+    	}
+    	
+    	instrumentRepository.delete(instrument);
+    	System.out.println("Instrument is deleted: " + id);
+		return ok("Instrument is deleted: " + id);
+    }
+    
+    public Result getInstrument(long id, String format) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	Instrument instrument = instrumentRepository.findOne(id);
+    	if (instrument == null) {
+    		System.out.println("Instrument not found with name: " + id);
+			return notFound("Instrument not found with name: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(instrument);
+    	}
+    	
+    	return ok(result);
+    }
+
+    
+    public Result getAllInstruments(String format) {
+    	try {
+    		Iterable<Instrument>instruments =  instrumentRepository.findAll();
+    		String result = new String();
+    		result = new Gson().toJson(instruments);
+    		return ok(result);
+    	} catch (Exception e) {
+    		return badRequest("Service Configurations not found");
+    	}
+    }
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/JournalPublicationController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/JournalPublicationController.java b/ApacheCMDA-Backend/app/controllers/JournalPublicationController.java
new file mode 100644
index 0000000..e4a304a
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/JournalPublicationController.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+import models.JournalPublication;
+import models.JournalPublicationRepository;
+import models.User;
+import models.UserRepository;
+import play.mvc.Controller;
+import play.mvc.Result;
+
+/**
+ * The main set of web services.
+ */
+@Named
+@Singleton
+public class JournalPublicationController extends Controller {
+	private final JournalPublicationRepository journalPublicationRepository;
+    private final UserRepository userRepository;
+	
+	// We are using constructor injection to receive a repository to support our desire for immutability.
+    @Inject
+    public JournalPublicationController(final JournalPublicationRepository journalPublicationRepository,
+    		final UserRepository userRepository) {
+        this.journalPublicationRepository = journalPublicationRepository;
+        this.userRepository = userRepository;
+    }
+    
+    public Result addJournalPublication() {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("JournalPublication not saved, expecting Json data");
+			return badRequest("JournalPublication not saved, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	String paperTitle = json.findPath("paperTitle").asText();
+    	long authorId = json.findPath("authorId").asLong();
+		String publicationChannel = json.findPath("publicationChannel").asText();
+		int year = json.findPath("year").asInt();
+		String journalName = json.findPath("journalName").asText();
+    	int volume = json.findPath("volume").asInt();
+		int column = json.findPath("column").asInt();
+		String page = json.findPath("page").asText();
+		
+		try {
+			User author = userRepository.findOne(authorId);
+			JournalPublication journalPublication = new JournalPublication(paperTitle, author, publicationChannel,
+					year, journalName, volume, column, page);
+			JournalPublication savedJournalPublication = journalPublicationRepository.save(journalPublication);
+			
+			System.out.println("JournalPublication saved: " + savedJournalPublication.getJournalName());
+			return created(new Gson().toJson(savedJournalPublication.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println(pe.getClass().toString());
+			System.out.println("JournalPublication not saved: " + journalName);
+			return badRequest("JournalPublication not saved: " + journalName);
+		}			
+    }
+    
+    public Result deleteJournalPublicationById(Long id) {
+    	JournalPublication journalPublication = journalPublicationRepository.findOne(id);
+    	if (journalPublication == null) {
+    		System.out.println("JournalPublication not found with id: " + id);
+			return notFound("JournalPublication not found with id: " + id);
+    	}
+    	
+    	journalPublicationRepository.delete(journalPublication);
+    	System.out.println("JournalPublication is deleted: " + id);
+		return ok("JournalPublication is deleted: " + id);
+    }
+    
+    public Result updateJournalPublicationById(long id) {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("JournalPublication not updated, expecting Json data");
+			return badRequest("JournalPublication not updated, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	String paperTitle = json.findPath("paperTitle").asText();
+    	long authorId = json.findPath("authorId").asLong();
+		String publicationChannel = json.findPath("publicationChannel").asText();
+		int year = json.findPath("year").asInt();
+		String journalName = json.findPath("journalName").asText();
+    	int volume = json.findPath("volume").asInt();
+		int column = json.findPath("column").asInt();
+		String page = json.findPath("page").asText();
+		
+		try {
+			User author = userRepository.findOne(authorId);
+			
+			JournalPublication journalPublication = journalPublicationRepository.findOne(id);
+			journalPublication.setPaperTitle(paperTitle);
+			journalPublication.setAuthor(author);
+			journalPublication.setPublicationChannel(publicationChannel);
+			journalPublication.setYear(year);
+			journalPublication.setJournalName(journalName);
+			journalPublication.setVolume(volume);
+			journalPublication.setColumn(column);
+			journalPublication.setPage(page);
+			
+			JournalPublication savedJournalPublication = journalPublicationRepository.save(journalPublication);
+			
+			System.out.println("JournalPublication updated: " + savedJournalPublication.getJournalName());
+			return created("JournalPublication updated: " + savedJournalPublication.getJournalName());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("JournalPublication not updated: " + id);
+			return badRequest("JournalPublication not updated: " + id);
+		}			
+    }
+    
+    public Result getJournalPublicationById(Long id, String format) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	
+    	JournalPublication journalPublication = journalPublicationRepository.findOne(id);
+    	if (journalPublication == null) {
+    		System.out.println("JournalPublication not found with id: " + id);
+			return notFound("JournalPublication not found with id: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(journalPublication);
+    	}
+    	
+    	return ok(result);
+    }
+    
+    public Result getAllJournalPublications(String format) {
+    	
+    	String result = new String();
+    	
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(journalPublicationRepository.findAll());
+    	}
+    			
+    	return ok(result);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/ParameterController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/ParameterController.java b/ApacheCMDA-Backend/app/controllers/ParameterController.java
new file mode 100644
index 0000000..899adce
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/ParameterController.java
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import java.util.Iterator;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+import models.ClimateService;
+import models.ClimateServiceRepository;
+import models.Parameter;
+import models.ParameterRepository;
+import play.mvc.Controller;
+import play.mvc.Result;
+
+/**
+ * The main set of web services.
+ */
+@Named
+@Singleton
+public class ParameterController extends Controller {
+	private final ParameterRepository parameterRepository;
+    private final ClimateServiceRepository climateServiceRepository;
+	
+	// We are using constructor injection to receive a repository to support our desire for immutability.
+    @Inject
+    public ParameterController(final ParameterRepository parameterRepository,
+    		final ClimateServiceRepository climateServiceRepository) {
+        this.parameterRepository = parameterRepository;
+        this.climateServiceRepository = climateServiceRepository;
+    }
+    
+    public Result addParameter() {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Parameter not saved, expecting Json data");
+			return badRequest("Parameter not saved, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	long serviceId = json.findPath("serviceId").asLong();
+    	long indexInService = json.findPath("indexInService").asLong();
+		String name = json.findPath("name").asText();
+		String dataRange = json.findPath("dataRange").asText();
+		String rule = json.findPath("rule").asText();
+		String purpose = json.findPath("purpose").asText();
+		
+		try {
+			ClimateService climateService = climateServiceRepository.findOne(serviceId);
+			Parameter parameter = new Parameter(climateService, indexInService, name,
+					dataRange, rule, purpose);
+			Parameter savedParameter = parameterRepository.save(parameter);
+			
+			System.out.println("Parameter saved: " + savedParameter.getName());
+			return created(new Gson().toJson(savedParameter.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println(serviceId);
+			System.out.println(pe.getClass().toString());
+			System.out.println("Parameter not saved: " + name);
+			return badRequest("Parameter not saved: " + name);
+		}			
+    }
+    
+    public Result deleteParameterByName(long serviceId, String name) {
+    	Parameter parameter = parameterRepository.findByNameAndClimateService_Id(name,serviceId);
+    	if (parameter == null) {
+    		System.out.println("Parameter not found with name: " + name);
+			return notFound("Parameter not found with name: " + name);
+    	}
+    	
+    	parameterRepository.delete(parameter);
+    	System.out.println("Parameter is deleted: " + name);
+		return ok("Parameter is deleted: " + name);
+    }
+    
+    public Result updateParameterByName(String oldName) {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Parameter not updated, expecting Json data");
+			return badRequest("Parameter not updated, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	long serviceId = json.findPath("serviceId").asLong();
+    	long indexInService = json.findPath("indexInService").asLong();
+		String name = json.findPath("name").asText();
+		Iterator<JsonNode> elements = json.findPath("dataType").elements();
+		StringBuffer dataType = new StringBuffer();
+		while (elements.hasNext()) {
+			dataType.append(elements.next().asText());
+			dataType.append(",");
+		}
+		dataType.deleteCharAt(dataType.length() - 1);
+		String dataRange = json.findPath("dataRange").asText();
+		String rule = json.findPath("rule").asText();
+		String purpose = json.findPath("purpose").asText();
+		
+		if (oldName == null || oldName.length() == 0) {
+    		System.out.println("Parameter Name is null or empty!");
+			return badRequest("Parameter Name is null or empty!");
+    	}
+		
+		try {
+			ClimateService climateService = climateServiceRepository.findOne(serviceId);
+			
+			Parameter parameter = parameterRepository.findByNameAndClimateService_Id(oldName, serviceId);
+			parameter.setClimateService(climateService);
+			parameter.setIndexInService(indexInService);
+			parameter.setName(name);
+			parameter.setDataRange(dataRange);
+			parameter.setRule(rule);
+			parameter.setPurpose(purpose);
+			
+			Parameter savedParameter = parameterRepository.save(parameter);
+			
+			System.out.println("Parameter updated: " + savedParameter.getName());
+			return created("Parameter updated: " + savedParameter.getName());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Parameter not updated: " + name);
+			return badRequest("Parameter not updated: " + name);
+		}			
+    }
+    
+    public Result updateParameterById(long id) {
+    	JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Parameter not updated, expecting Json data");
+			return badRequest("Parameter not updated, expecting Json data");
+    	}
+
+    	//Parse JSON file
+    	long serviceId = json.findPath("serviceId").asLong();
+    	long indexInService = json.findPath("indexInService").asLong();
+		String name = json.findPath("name").asText();
+		Iterator<JsonNode> elements = json.findPath("dataType").elements();
+		StringBuffer dataType = new StringBuffer();
+		while (elements.hasNext()) {
+			dataType.append(elements.next().asText());
+			dataType.append(",");
+		}
+		dataType.deleteCharAt(dataType.length() - 1);
+		String dataRange = json.findPath("dataRange").asText();
+		String rule = json.findPath("rule").asText();
+		String purpose = json.findPath("purpose").asText();
+		
+		try {
+			ClimateService climateService = climateServiceRepository.findOne(serviceId);
+			
+			Parameter parameter = parameterRepository.findOne(id);
+			parameter.setClimateService(climateService);
+			parameter.setIndexInService(indexInService);
+			parameter.setName(name);
+			parameter.setDataRange(dataRange);
+			parameter.setRule(rule);
+			parameter.setPurpose(purpose);
+			
+			Parameter savedParameter = parameterRepository.save(parameter);
+			
+			System.out.println("Parameter updated: " + savedParameter.getName());
+			return created("Parameter updated: " + savedParameter.getName());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Parameter not updated: " + name);
+			return badRequest("Parameter not updated: " + name);
+		}			
+    }
+    
+    public Result getParameterByName(long serviceId, String name, String format) {
+    	if (name == null || name.length() == 0) {
+    		System.out.println("Parameter Name is null or empty!");
+			return badRequest("Parameter Name is null or empty!");
+    	}
+    	
+    	Parameter parameter = parameterRepository.findByNameAndClimateService_Id(name, serviceId);
+    	if (parameter == null) {
+    		System.out.println("Parameter not found with name: " + name);
+			return notFound("Parameter not found with name: " + name);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(parameter);
+    	}
+    	
+    	return ok(result);
+    }
+    
+    public Result getParameterById(Long id, String format) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	
+    	Parameter parameter = parameterRepository.findOne(id);
+    	if (parameter == null) {
+    		System.out.println("Parameter not found with id: " + id);
+			return notFound("Parameter not found with id: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(parameter);
+    	}
+    	
+    	return ok(result);
+    }
+    
+    public Result getAllParameters(String format) {
+    	
+    	String result = new String();
+    	
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(parameterRepository.findAll());
+    	}
+    			
+    	return ok(result);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/ServiceConfigurationController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/ServiceConfigurationController.java b/ApacheCMDA-Backend/app/controllers/ServiceConfigurationController.java
new file mode 100644
index 0000000..cbd1e9c
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/ServiceConfigurationController.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import java.util.List;
+
+import play.mvc.*;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.inject.Inject;
+import javax.persistence.PersistenceException;
+
+import models.ClimateService;
+import models.ClimateServiceRepository;
+import models.ServiceConfiguration;
+import models.ServiceConfigurationRepository;
+import models.User;
+import models.UserRepository;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+/**
+ * The main set of web services.
+ */
+@Named
+@Singleton
+public class ServiceConfigurationController extends Controller {
+	
+	private final ServiceConfigurationRepository serviceConfigurationRepository;
+	private final ClimateServiceRepository climateServiceRepository;
+	private final UserRepository userRepository;
+	
+	@Inject
+	public ServiceConfigurationController(final ServiceConfigurationRepository serviceConfigurationRepository, 
+			UserRepository userRepository, ClimateServiceRepository climateServiceRepository) {
+		this.serviceConfigurationRepository = serviceConfigurationRepository;
+		this.climateServiceRepository = climateServiceRepository;
+		this.userRepository = userRepository;
+	}
+	
+	public Result addServiceConfiguration() {
+		JsonNode json = request().body().asJson();
+    	if (json == null) {
+    		System.out.println("Service Configuration not saved, expecting Json data");
+			return badRequest("Service Configuration not saved, expecting Json data");
+    	}
+    	long serviceId = json.findPath("serviceId").asLong();
+    	long userId = json.findPath("userId").asLong();
+    	String runTime = json.findPath("runTime").asText();
+
+    	try {
+			User user = userRepository.findOne(userId);
+			ClimateService climateService = climateServiceRepository.findOne(serviceId);
+			ServiceConfiguration serviceConfiguration = new ServiceConfiguration(climateService,
+					user, runTime);
+			ServiceConfiguration savedServiceConfiguration = serviceConfigurationRepository.save(serviceConfiguration);
+			System.out.println("Service Configuration saved: "+ savedServiceConfiguration.getId());
+			return created(new Gson().toJson(savedServiceConfiguration.getId()));
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Service Configuration not created");
+			return badRequest("Service Configuration not created");
+		}
+    	
+	}
+	
+    public Result updateServiceConfigurationById(long id) {
+		if (id < 0) {
+			System.out.println("id is negative!");
+			return badRequest("id is negative!");
+		}
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out.println("Service Configuration not saved, expecting Json data");
+			return badRequest("Service Configuration not saved, expecting Json data");
+		}
+		long serviceId = json.findPath("serviceId").asLong();
+		long userId = json.findPath("userId").asLong();
+		String runTime = json.findPath("runTime").asText();
+
+
+	
+		try {
+			ServiceConfiguration serviceConfiguration = serviceConfigurationRepository.findOne(id);
+			serviceConfiguration.setRunTime(runTime);
+			ClimateService climateService = climateServiceRepository.findOne(serviceId);
+			serviceConfiguration.setClimateservice(climateService);
+			User user = userRepository.findOne(userId);
+			serviceConfiguration.setUser(user);
+			ServiceConfiguration savedServiceConfiguration = serviceConfigurationRepository.save(serviceConfiguration);
+			
+			System.out.println("Service Configuration updated: "+ savedServiceConfiguration.getId());
+			return created("Service Configuration updated: "+ savedServiceConfiguration.getId());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("Service Configuration not saved: "+id);
+			return badRequest("Service Configuration not saved: "+id);
+		}			
+	}
+
+	
+    public Result deleteServiceConfiguration(long id) {
+    	if (id < 0) {
+    		System.out.println("id is negative!");
+			return badRequest("id is negative!");
+    	}
+    	ServiceConfiguration serviceConfiguration = serviceConfigurationRepository.findOne(id);
+    	if (serviceConfiguration == null) {
+    		System.out.println("Service Configuration not found with id: " + id);
+			return notFound("Service Configuration not found with id: " + id);
+    	}
+    	
+    	serviceConfigurationRepository.delete(serviceConfiguration);
+    	System.out.println("Service Configuration is deleted: " + id);
+		return ok("Service Configuration is deleted: " + id);
+    }
+    public Result getServiceConfiguration(long id, String format) {
+    	ServiceConfiguration serviceConfiguration = serviceConfigurationRepository.findOne(id);
+    	if (serviceConfiguration == null) {
+    		System.out.println("Service Configuration not found with name: " + id);
+			return notFound("Service Configuration not found with name: " + id);
+    	}
+    	
+    	String result = new String();
+    	if (format.equals("json")) {
+    		result = new Gson().toJson(serviceConfiguration);
+    	}
+    	
+    	return ok(result);
+    }
+    
+    public Result getServiceConfigurationsByUser(long userId, String format) {
+    	if (userId < 0) {
+    		System.out.println("userId is negative!");
+			return badRequest("userId is negative!");
+    	}
+    	try {
+			User user = userRepository.findOne(userId);
+			if (user == null) {
+				System.out.println("Cannot find User by id: "+userId);
+				return notFound("Cannot find User by id: "+userId);
+			}
+			List<ServiceConfiguration> serviceConfigurations = serviceConfigurationRepository.findAllByUser(user);
+			String result = new String();
+	    	if (format.equals("json")) {
+	    		result = new Gson().toJson(serviceConfigurations);
+	    	}
+	    	return ok(result);
+		} catch (PersistenceException pe) {
+			System.out.println("Service Configuration not found by userId: "+userId);
+			return notFound("Service Configuration not found by userId: "+userId);
+		}
+    }
+    
+    public Result getAllServiceConfigurations() {
+    	try {
+    		Iterable<ServiceConfiguration> serviceConfigurations =  serviceConfigurationRepository.findAll();
+    		String result = new String();
+    		result = new Gson().toJson(serviceConfigurations);
+    		return ok(result);
+    	} catch (Exception e) {
+    		return badRequest("Service Configurations not found");
+    	}
+    }
+	
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/37774c92/ApacheCMDA-Backend/app/controllers/ServiceConfigurationItemController.java
----------------------------------------------------------------------
diff --git a/ApacheCMDA-Backend/app/controllers/ServiceConfigurationItemController.java b/ApacheCMDA-Backend/app/controllers/ServiceConfigurationItemController.java
new file mode 100644
index 0000000..f2540fb
--- /dev/null
+++ b/ApacheCMDA-Backend/app/controllers/ServiceConfigurationItemController.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package controllers;
+
+import java.util.List;
+
+import models.Parameter;
+import models.ParameterRepository;
+import models.ServiceConfiguration;
+import models.ServiceConfigurationItem;
+import models.ServiceConfigurationItemRepository;
+import models.ServiceConfigurationRepository;
+import play.mvc.*;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.persistence.PersistenceException;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.Gson;
+
+/**
+ * The main set of web services.
+ */
+@Named
+@Singleton
+public class ServiceConfigurationItemController extends Controller {
+
+	private final ServiceConfigurationItemRepository serviceConfigurationItemRepository;
+	private final ServiceConfigurationRepository serviceConfigurationRepository;
+	private final ParameterRepository parameterRepository;
+	// We are using constructor injection to receive a repository to support our
+	// desire for immutability.
+	@Inject
+	public ServiceConfigurationItemController(
+			final ServiceConfigurationRepository serviceConfigurationRepository,
+			final ParameterRepository parameterRepository,
+			final ServiceConfigurationItemRepository serviceConfigurationItemRepository) {
+			 
+		this.parameterRepository = parameterRepository;
+		this.serviceConfigurationItemRepository = serviceConfigurationItemRepository;
+		this.serviceConfigurationRepository = serviceConfigurationRepository;
+		//this.parameterOptionRepository = parameterOptionRepository;
+	}
+
+	public Result addServiceConfigurationItem() {
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out
+					.println("ServiceConfigurationItem not saved, expecting Json data");
+			return badRequest("ServiceConfigurationItem not saved, expecting Json data");
+		}
+
+		// Parse JSON file
+		long serviceConfigurationId = json.findPath("serviceConfigurationId").asLong();
+		long parameterId = json.findPath("parameterId").asLong();
+		String value = json.findPath("value").asText();
+
+		try {
+			ServiceConfiguration serviceConfiguration = serviceConfigurationRepository
+					.findOne(serviceConfigurationId);
+			Parameter parameter = parameterRepository.findOne(parameterId);	
+			ServiceConfigurationItem newConfigItem = new ServiceConfigurationItem(
+					serviceConfiguration, parameter, value);
+			serviceConfigurationItemRepository.save(newConfigItem);
+
+			System.out.println("ServiceConfigurationItem saved: "
+					+ newConfigItem.getValue());
+			return created("ServiceConfigurationItem saved: "
+					+ newConfigItem.getValue());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("ServiceConfigurationItem not saved: " + value);
+			return badRequest("ServiceConfigurationItem not saved: " + value);
+		}
+	}
+
+	public Result deleteServiceConfigurationItemById(long id) {
+		ServiceConfigurationItem delConfigItem = serviceConfigurationItemRepository
+				.findOne(id);
+		if (delConfigItem == null) {
+			System.out.println("ServiceConfigurationItem not found with id: "
+					+ id);
+			return notFound("ServiceConfigurationItem not found with id: " + id);
+		}
+
+		serviceConfigurationItemRepository.delete(delConfigItem);
+		System.out.println("ServiceConfigurationItem is deleted: " + id);
+		return ok("ServiceConfigurationItem is deleted: " + id);
+	}
+
+	public Result updateServiceConfigurationItemById(long id) {
+		JsonNode json = request().body().asJson();
+		if (json == null) {
+			System.out
+					.println("Climate service not saved, expecting Json data");
+			return badRequest("Climate service not saved, expecting Json data");
+		}
+
+		// Parse JSON file
+		long serviceConfigurationId = json.findPath("serviceConfigurationId").asLong();
+		long parameterId = json.findPath("parameterId").asLong();
+		String value = json.findPath("value").asText();
+
+		try {
+
+			ServiceConfiguration serviceConfiguration = serviceConfigurationRepository
+					.findOne(serviceConfigurationId);
+			Parameter param = parameterRepository.findOne(parameterId);
+
+			if (serviceConfiguration != null || param != null || value != null)
+				return ok("Nothing to update, ServiceConfigItem unchanged");
+
+			ServiceConfigurationItem configItem = new ServiceConfigurationItem(
+					serviceConfiguration, param, value);
+			configItem.setServiceConfiguration(serviceConfiguration);
+			configItem.setParameter(param);
+			configItem.setValue(value);
+
+			serviceConfigurationItemRepository.save(configItem);
+
+			System.out.println("ServiceConfigItem updated: "
+					+ configItem.getValue());
+			return ok("ServiceConfigItem updated: " + configItem.getValue());
+		} catch (PersistenceException pe) {
+			pe.printStackTrace();
+			System.out.println("ServiceConfigItem not updated: " + value);
+			return badRequest("ServiceConfigItem not updated: " + value);
+		}
+	}
+
+	public Result getServiceConfigurationItemByParameterId(long parameterId) {
+		if (parameterId < 0) {
+			System.out.println("Parameter Id is invalid!");
+			return badRequest("Parameter Id is invalid!");
+		}
+
+		List<ServiceConfigurationItem> serviceConfigItem = serviceConfigurationItemRepository
+				.findByParameter_Id(parameterId);
+		if (serviceConfigItem == null) {
+			System.out.println("ServiceConfigurationItem not found with id: "
+					+ parameterId);
+			return notFound("ServiceConfigurationItem not found with id: "
+					+ parameterId);
+		}
+
+		String result = new Gson().toJson(serviceConfigItem);
+
+		return ok(result);
+	}
+
+	public Result getServiceConfigurationItemById(Long id) {
+		if (id == null) {
+			System.out.println("ServiceConfigItem id is null or empty!");
+			return badRequest("ServiceConfigItem id is null or empty!");
+		}
+
+		ServiceConfigurationItem serviceConfigItem = serviceConfigurationItemRepository
+				.findOne(id);
+		if (serviceConfigItem == null) {
+			System.out.println("ServiceConfigurationItem not found with id: "
+					+ id);
+			return notFound("ServiceConfigurationItem not found with id: " + id);
+		}
+
+		String result = new Gson().toJson(serviceConfigItem);
+
+		return ok(result);
+	}
+
+	public Result getServiceConfigurationItemsInServiceConfig(Long serviceConfigurationId) {
+		if (serviceConfigurationId == null) {
+			System.out.println("ServiceConfig id is null or empty!");
+			return badRequest("ServiceConfig id is null or empty!");
+		}
+
+		List<ServiceConfigurationItem> serviceConfigItems = serviceConfigurationItemRepository
+				.findByServiceConfiguration_Id(serviceConfigurationId);
+		System.out.println(serviceConfigItems.size());
+		String result = new Gson().toJson(serviceConfigItems);
+		System.out.println(result);
+		return ok(result);
+	}
+
+}