Remove Device and Sensor Type

Project: http://git-wip-us.apache.org/repos/asf/incubator-cmda/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cmda/commit/247a7178
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cmda/tree/247a7178
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cmda/diff/247a7178

Branch: refs/heads/master
Commit: 247a717809052c30606475bf899d97f2cf3ed098
Parents: 6c887ad
Author: mingqi830 <m...@andrew.cmu.edu>
Authored: Wed Sep 2 15:31:25 2015 -0700
Committer: mingqi830 <m...@andrew.cmu.edu>
Committed: Wed Sep 2 15:31:25 2015 -0700

----------------------------------------------------------------------
 app/controllers/DeviceTypeController.java | 129 -----------------------
 app/controllers/SensorTypeController.java | 140 -------------------------
 app/views/deviceTypes.scala.html          | 102 ------------------
 app/views/header.scala.html               |   4 +-
 app/views/sensorTypes.scala.html          | 136 ------------------------
 conf/routes                               |  12 ---
 6 files changed, 2 insertions(+), 521 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/247a7178/app/controllers/DeviceTypeController.java
----------------------------------------------------------------------
diff --git a/app/controllers/DeviceTypeController.java 
b/app/controllers/DeviceTypeController.java
deleted file mode 100644
index 3a2a224..0000000
--- a/app/controllers/DeviceTypeController.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2013 Carnegie Mellon University Silicon Valley. 
- * All rights reserved. 
- * 
- * This program and the accompanying materials are made available
- * under the terms of dual licensing(GPL V2 for Research/Education
- * purposes). GNU Public License v2.0 which accompanies this distribution
- * is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Please contact http://www.cmu.edu/silicon-valley/ if you have any 
- * questions.
- * 
- * */
-package controllers;
-
-import java.util.*;
-
-import com.fasterxml.jackson.databind.*;
-import com.fasterxml.jackson.databind.node.*;
-
-import play.libs.Json;
-import models.metadata.DeviceType;
-import play.data.DynamicForm;
-import play.data.Form;
-import play.mvc.*;
-import util.APICall;
-import util.APICall.ResponseType;
-import views.html.*;
-
-//@Security.Authenticated(Secured.class)
-public class DeviceTypeController extends Controller {
-       final static Form<DeviceType> deviceTypeForm = 
Form.form(DeviceType.class);
-
-       public static Result deviceTypes() {
-               // if (Secured.isLoggedIn())
-               // return ok(deviceTypes.render(DeviceType.all(), 
deviceTypeForm));
-               // else
-               // return forbidden();
-               return ok(deviceTypes.render(DeviceType.all(), deviceTypeForm));
-       }
-
-       public static Result newDeviceType() {
-               // Form<DeviceType> dt = deviceTypeForm.bindFromRequest();
-               Map<String, String[]> dtFormEncoded = request().body()
-                               .asFormUrlEncoded();
-               try {
-                       ObjectNode jsonData = Json.newObject();
-                       String deviceTypeName = 
dtFormEncoded.get("deviceTypeName")[0];
-
-                       // should not contain spaces
-                       if (deviceTypeName != null && !deviceTypeName.isEmpty()
-                                       && !deviceTypeName.contains(" ")) {
-                               jsonData.put("deviceTypeName", deviceTypeName);
-                       }
-                       jsonData.put("manufacturer", 
dtFormEncoded.get("manufacturer")[0]);
-                       jsonData.put("version", 
dtFormEncoded.get("version")[0]);
-                       jsonData.put("deviceTypeUserDefinedFields",
-                                       
dtFormEncoded.get("deviceTypeUserDefinedFields")[0]);
-
-                       ArrayNode arrayNode = 
jsonData.putArray("sensorTypeNames");
-                       for (int i = 0; i < 
dtFormEncoded.get("sensorTypeNames").length; i++) {
-                               
arrayNode.add(dtFormEncoded.get("sensorTypeNames")[i]);
-                       }
-
-                       // create the item by calling the API
-                       JsonNode response = DeviceType.create(jsonData);
-
-                       // flash the response message
-                       Application.flashMsg(response);
-               } catch (IllegalStateException e) {
-                       e.printStackTrace();
-                       Application.flashMsg(APICall
-                                       
.createResponse(ResponseType.CONVERSIONERROR));
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       
Application.flashMsg(APICall.createResponse(ResponseType.UNKNOWN));
-               }
-               return redirect("/deviceTypes");
-       }
-
-       public static Result editDeviceType() {
-               DynamicForm df = DynamicForm.form().bindFromRequest();
-               ObjectNode jsonData = Json.newObject();
-               try {
-                       String deviceTypeName = df.field("pk").value();
-
-                       if (deviceTypeName != null && 
!deviceTypeName.isEmpty()) {
-                               jsonData.put("deviceTypeName", deviceTypeName);
-                       }
-
-                       String editField = df.field("name").value();  
-                       if (editField != null && !editField.isEmpty()) {
-                               jsonData.put(editField, 
df.field("value").value());
-                       }
-
-                       // Call the edit() method
-                       JsonNode response = DeviceType.edit(deviceTypeName, 
jsonData);
-
-                       // flash the response message
-                       Application.flashMsg(response);
-
-               } catch (IllegalStateException e) {
-                       e.printStackTrace();
-                       Application.flashMsg(APICall
-                                       
.createResponse(ResponseType.CONVERSIONERROR));
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       
Application.flashMsg(APICall.createResponse(ResponseType.UNKNOWN));
-               }
-
-               return ok("updated");
-       }
-
-       public static Result deleteDeviceType() {
-               DynamicForm df = DynamicForm.form().bindFromRequest();
-               String deviceTypeName = df.field("idHolder").value();
-
-               // Call the delete() method
-               JsonNode response = DeviceType.delete(deviceTypeName);
-
-               // flash the response message
-               Application.flashMsg(response);
-               return redirect("/deviceTypes");
-
-       }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/247a7178/app/controllers/SensorTypeController.java
----------------------------------------------------------------------
diff --git a/app/controllers/SensorTypeController.java 
b/app/controllers/SensorTypeController.java
deleted file mode 100644
index f78a22d..0000000
--- a/app/controllers/SensorTypeController.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2013 Carnegie Mellon University Silicon Valley. 
- * All rights reserved. 
- * 
- * This program and the accompanying materials are made available
- * under the terms of dual licensing(GPL V2 for Research/Education
- * purposes). GNU Public License v2.0 which accompanies this distribution
- * is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * 
- * Please contact http://www.cmu.edu/silicon-valley/ if you have any 
- * questions.
- * 
- * */
-package controllers;
-
-import com.fasterxml.jackson.databind.*;
-import com.fasterxml.jackson.databind.node.*;
-
-import models.metadata.SensorType;
-import play.data.DynamicForm;
-import play.data.Form;
-import play.libs.Json;
-import play.mvc.*;
-import util.APICall;
-import util.APICall.ResponseType;
-import views.html.*;
-
-public class SensorTypeController extends Controller {
-       final static Form<SensorType> sensorTypeForm = 
Form.form(SensorType.class);
-
-       public static Result sensorTypes() {
-               return ok(sensorTypes.render(SensorType.all(), sensorTypeForm));
-       }
-
-       public static Result newSensorType() {
-               Form<SensorType> st = sensorTypeForm.bindFromRequest();
-
-               ObjectNode jsonData = Json.newObject();
-
-               try {
-
-                       String sensorTypeName = 
st.field("sensorTypeName").value();
-
-                       // should not contain spaces
-                       if (sensorTypeName != null && !sensorTypeName.isEmpty()
-                                       && !sensorTypeName.contains(" ")) {
-                               jsonData.put("sensorTypeName", sensorTypeName);
-                       }
-                       jsonData.put("manufacturer", 
st.field("manufacturer").value());
-
-                       String version = st.field("version").value();
-                       if (version != null && !version.isEmpty()) {
-                               jsonData.put("version", 
Double.valueOf(version));
-                       }
-                       String maximumValue = st.field("maximumValue").value();
-                       if (maximumValue != null && !maximumValue.isEmpty()) {
-                               jsonData.put("maximumValue", 
Double.valueOf(maximumValue));
-                       }
-                       String minimumValue = st.field("minimumValue").value();
-                       if (minimumValue != null && !minimumValue.isEmpty()) {
-                               jsonData.put("minimumValue", 
Double.valueOf(minimumValue));
-                       }
-                       String unit = st.field("unit").value();
-                       if (unit != null && !unit.isEmpty()) {
-                               jsonData.put("unit", unit);
-                       }
-                       String interpreter = st.field("interpreter").value();
-                       if (interpreter != null && !interpreter.isEmpty()) {
-                               jsonData.put("interpreter", interpreter);
-                       }
-                       jsonData.put("sensorCategoryName", 
st.field("sensorCategoryName")
-                                       .value());
-                       jsonData.put("sensorTypeUserDefinedFields",
-                                       
st.field("sensorTypeUserDefinedFields").value());
-
-                       // create the item by calling the API
-                       JsonNode response = SensorType.create(jsonData);
-
-                       // flash the response message
-                       Application.flashMsg(response);
-               } catch (IllegalStateException e) {
-                       e.printStackTrace();
-                       Application.flashMsg(APICall
-                                       
.createResponse(ResponseType.CONVERSIONERROR));
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       
Application.flashMsg(APICall.createResponse(ResponseType.UNKNOWN));
-               }
-
-               return redirect("/sensorTypes");
-       }
-
-       public static Result editSensorType() {
-               DynamicForm df = DynamicForm.form().bindFromRequest();
-               ObjectNode jsonData = Json.newObject();
-               try {
-                       String sensorTypeName = df.field("pk").value();
-
-                       if (sensorTypeName != null && 
!sensorTypeName.isEmpty()) {
-                               jsonData.put("sensorTypeName", sensorTypeName);
-                       }
-
-                       String editField = df.field("name").value();  
-                       if (editField != null && !editField.isEmpty()) {
-                               jsonData.put(editField, 
df.field("value").value());
-                       }
-                       
-                       // Call the edit() method
-                       JsonNode response = SensorType.edit(jsonData);
-
-                       // flash the response message
-                       Application.flashMsg(response);
-
-               } catch (IllegalStateException e) {
-                       e.printStackTrace();
-                       Application.flashMsg(APICall
-                                       
.createResponse(ResponseType.CONVERSIONERROR));
-               } catch (Exception e) {
-                       e.printStackTrace();
-                       
Application.flashMsg(APICall.createResponse(ResponseType.UNKNOWN));
-               }
-               return ok("updated");
-       }
-       
-       public static Result deleteSensorType() {
-               DynamicForm df = DynamicForm.form().bindFromRequest();
-               String sensorTypeName = df.field("idHolder").value();
-
-               // Call the delete() method
-               JsonNode response = SensorType.delete(sensorTypeName);
-
-               // flash the response message
-               Application.flashMsg(response);
-
-               return redirect("/sensorTypes");
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/247a7178/app/views/deviceTypes.scala.html
----------------------------------------------------------------------
diff --git a/app/views/deviceTypes.scala.html b/app/views/deviceTypes.scala.html
deleted file mode 100644
index 98e93dc..0000000
--- a/app/views/deviceTypes.scala.html
+++ /dev/null
@@ -1,102 +0,0 @@
-
-@(deviceTypes: List[metadata.DeviceType], deviceTypeForm: 
play.data.Form[metadata.DeviceType])
-
-@import helper._
-
-@scripts = {
-       <script src='@routes.Assets.at("javascripts/edit_button.js")'></script>
-}
-
-@main("DeviceTypes", scripts) {
-    
-    @flash_message()
-    
-    <h1>@deviceTypes.size() Devices Types</h1>
-    <table class="table table-striped table-bordered table-condensed">
-           <tr>
-               <td>Device Type Name</td>   
-               <td>Manufacturer</td>
-               <td>Version</td>
-               <td>Sensor Type Names</td>
-               <td>User Defined Fields</td>
-                                                       
-               @if(session.get("email")){
-                       <td>Operation</td>
-               }
-           </tr>
-
-       @for(deviceType <- deviceTypes) {
-       <tr>
-            <td>@deviceType.getDeviceTypeName()</td>
-            <td>@deviceType.getManufacturer()</td>
-            <td>@deviceType.getVersion()</td>
-               <td>@deviceType.getSensorTypeNames()</td>
-            <td>
-            <span class="@deviceType.getDeviceTypeName() editable"
-               data-name='deviceTypeUserDefinedFields'>
-               @deviceType.getDeviceTypeUserDefinedFields()
-            </span>
-            </td>
-               @if(session.get("email")){
-                       
-                       <td class="operation">
-                                               <input type="button" 
class="edit-btn btn btn-primary" value="Edit" 
-                                                       
data-pk='@deviceType.getDeviceTypeName()' 
-                                                       
data-url='@routes.DeviceTypeController.editDeviceType()' 
-                                               >                               
                
-                               
@form(routes.DeviceTypeController.deleteDeviceType()){
-                                               <input name="idHolder" 
type="hidden" value="@deviceType.getDeviceTypeName()">
-                                                               <input 
type="submit"  class="btn btn-danger" value="Delete" onclick="return 
confirm('Are you sure you want to delete this item?')">
-                               }
-                                       
-                       </td>
-            }
-       </tr>
-        }
-    </table>
-    
-    @if(session.get("email")){
-    <h2>Add a new device type</h2>
-
-           @form(action = routes.DeviceTypeController.newDeviceType()) {
-               
-                   @inputText(
-                       deviceTypeForm("deviceTypeName"), 
-                       '_label -> "Device Type Name * (Please DO NOT contain 
spaces)",                 
-                       '_error -> deviceTypeForm.globalError                   
             
-                   )
-                   @inputText(
-                       deviceTypeForm("manufacturer"), 
-                       '_label -> "Manufacturer", 
-                       '_error -> deviceTypeForm.globalError                   
             
-                   )
-                   @inputText(
-                       deviceTypeForm("version"), 
-                       '_label -> "Version",
-                       '_error -> deviceTypeForm.globalError                   
             
-                   )
-                   @inputText(
-                       deviceTypeForm("deviceTypeUserDefinedFields"),
-                       '_label -> "User Defined Fields",
-                       '_error -> deviceTypeForm.globalError
-                   )
-                   <dt>
-                       <label>Sensor Type Name</label>
-                   </dt>
-                   <dd>
-                           <select id="sensorTypeNames" name="sensorTypeNames" 
multiple>
-                               @for(sensorTypeName <- 
metadata.SensorType.allSensorTypeName()) {
-                                       <option 
value="@sensorTypeName">@sensorTypeName</option>
-                               }
-                           </select>
-                   </dd>
-                  
-             
-               <div class="actions">
-                   <input type="submit" class="btn primary" value="Register">
-                   <a href="@routes.DeviceTypeController.deviceTypes()" 
class="btn">Cancel</a>
-               </div>
-               
-           }
-       }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/247a7178/app/views/header.scala.html
----------------------------------------------------------------------
diff --git a/app/views/header.scala.html b/app/views/header.scala.html
index c270786..80d13c3 100644
--- a/app/views/header.scala.html
+++ b/app/views/header.scala.html
@@ -24,9 +24,9 @@
                                                <ul class="dropdown-menu">
                                                        <li><a 
href="@routes.SensorCategoryController.sensorCategories()">1. Sensor
                                                                        
Categories</a></li>
-                                                       <li><a 
href="@routes.SensorTypeController.sensorTypes()">2. Sensor
+                                                       <li><a href="">2. Sensor
                                                                        
Types</a></li>
-                                                       <li><a 
href="@routes.DeviceTypeController.deviceTypes()">3. Device Types</a></li>      
                                                 
+                                                       <li><a href="">3. 
Device Types</a></li>                                                 
                                                        <li><a 
href="@routes.DeviceController.devices()">4. Devices</a></li>
                                                        <li><a 
href="@routes.SensorController.sensors()">5. Sensors</a></li>
                                                </ul></li>

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/247a7178/app/views/sensorTypes.scala.html
----------------------------------------------------------------------
diff --git a/app/views/sensorTypes.scala.html b/app/views/sensorTypes.scala.html
deleted file mode 100644
index dced489..0000000
--- a/app/views/sensorTypes.scala.html
+++ /dev/null
@@ -1,136 +0,0 @@
-
-@(sensorTypes: List[metadata.SensorType], sensorTypeForm: 
play.data.Form[metadata.SensorType])
-
-@import helper._
-@import helper.twitterBootstrap._
-
-@scripts = {
-       <script src='@routes.Assets.at("javascripts/edit_button.js")'></script>
-}
-
-@main("Sensor Types", scripts) {
-    
-    @flash_message()
-    
-    <h1>@sensorTypes.size() Sensor Types</h1>
-    <table class="table table-striped table-bordered table-condensed">
-    <tr>
-       <td>Sensor Type Name</td>
-       <td>Manufacturer</td>
-       <td>Version</td>
-       <td>Max Value</td>
-       <td>Min Value</td>
-       <td>Unit</td>
-       <td>Interpreter</td>
-       <td>Sensor Category</td>
-       <td>User Defined Fields</td>
-       
-       
-       @if(session.get("email")){
-       <td>Operation</td>
-       }
-    </tr>
-
-        @for(sensorType <- sensorTypes) {
-    <tr id="@sensorType.getId()">
-            <td>@sensorType.getSensorTypeName()</td>
-                <td>@sensorType.getManufacturer()</td>
-                <td>@sensorType.getVersion()</td>
-                <td>@sensorType.getMaxValue()</td>
-                <td>@sensorType.getMinValue()</td>
-                <td>@sensorType.getUnit()</td>
-                <td>@sensorType.getInterpreter()</td>
-                <td>@sensorType.getSensorCategoryName()</td>
-                <td>
-                       <span class="@sensorType.getSensorTypeName() editable"
-                               data-name='sensorTypeUserDefinedFields'>
-                               @sensorType.getSensorTypeUserDefinedFields()
-                       </span>
-                </td>
-                
-                       @if(session.get("email")){
-
-                       <td class="operation">
-                                               
-                                               <input type="button" 
class="edit-btn btn btn-primary" value="Edit" 
-                                                       
data-pk='@sensorType.getSensorTypeName()' 
-                                                       
data-url='@routes.SensorTypeController.editSensorType()' 
-                                               >
-                                               
-                                               
-                                
@form(routes.SensorTypeController.deleteSensorType()){
-                                       <input name="idHolder" type="hidden" 
value="@sensorType.getSensorTypeName()">
-                                               <input type="submit"  
class="btn btn-danger" value="Delete" onclick="return confirm('Are you sure you 
want to delete this item?')">
-                               }
-                               </td>
-                               
-               }
-    </tr>
-        }
-    </table>
-    
-    
-    @if(session.get("email")){
-    <h2>Add a new sensor type</h2>
-    
-    @form(routes.SensorTypeController.newSensorType()) {
-         
-        @inputText(
-                sensorTypeForm("sensorTypeName"), 
-                '_label -> "Sensor Type Name * (Please DO NOT contain 
spaces)",     
-                'size -> 30,
-                'placeholder-> "the name of this sensor type",           
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @inputText(
-                sensorTypeForm("manufacturer"), 
-                '_label -> "Manufacturer",  
-                'size -> 30,
-                'placeholder-> "the name of Manufacturer",               
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @inputText(
-                sensorTypeForm("version"), 
-                '_label -> "Version",
-                'placeholder-> 1.0,                 
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @inputText(
-                sensorTypeForm("maximumValue"), 
-                '_label -> "Max Value",
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @inputText(
-                sensorTypeForm("minimumValue"), 
-                '_label -> "Min Value",                 
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @inputText(
-                sensorTypeForm("unit"), 
-                '_label -> "Unit",                 
-                'placeholder-> "Celsius",                 
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @inputText(
-                sensorTypeForm("interpreter"), 
-                '_label -> "Interpreter",                 
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        @select(
-                       sensorTypeForm("sensorCategoryName"), 
-                options(metadata.SensorCategory.allSensorCategoryName()),
-                       '_label -> "Sensor Category",
-                '_error -> sensorTypeForm.globalError
-                       )
-                       
-         @inputText(
-                sensorTypeForm("sensorTypeUserDefinedFields"), 
-                '_label -> "User Defined Fields",                     
-                '_error -> sensorTypeForm.globalError                          
      
-        )
-        <input class="btn" type="submit" value="Register">
-        <a href="@routes.SensorTypeController.sensorTypes()" 
class="btn">Cancel</a>
-        
-    }
-               }   
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cmda/blob/247a7178/conf/routes
----------------------------------------------------------------------
diff --git a/conf/routes b/conf/routes
index 59a4927..62c756a 100644
--- a/conf/routes
+++ b/conf/routes
@@ -35,18 +35,6 @@ POST        /solve/report                                    
    controllers.Bug
 # Map static resources from the /public folder to the /assets URL path
 GET         /assets/*file                                        
controllers.Assets.at(path="/public", file)
 
-# sensor_types
-GET         /sensorTypes                                         
controllers.SensorTypeController.sensorTypes()
-POST        /new/sensorTypes                                     
controllers.SensorTypeController.newSensorType()
-POST        /delete/sensorTypes                                  
controllers.SensorTypeController.deleteSensorType()
-POST        /edit/sensorTypes                                    
controllers.SensorTypeController.editSensorType()
-
-# device_types
-GET         /deviceTypes                                         
controllers.DeviceTypeController.deviceTypes()
-POST        /new/deviceTypes                                     
controllers.DeviceTypeController.newDeviceType()
-POST        /delete/deviceTypes                                  
controllers.DeviceTypeController.deleteDeviceType()
-POST        /edit/deviceTypes                                    
controllers.DeviceTypeController.editDeviceType()
-
 # devices
 GET         /devices                                             
controllers.DeviceController.devices()
 POST        /new/devices                                         
controllers.DeviceController.newDevice()

Reply via email to