You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/02/09 16:55:55 UTC

[27/50] [abbrv] airavata-php-gateway git commit: Admin now has to remove connections of app module with interface and deployments before being able to delete it.

Admin now has to remove connections of app module with interface and deployments before being able to delete it.


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/93c1b32a
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/93c1b32a
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/93c1b32a

Branch: refs/heads/master
Commit: 93c1b32a3f68f99cb402909e550cfa1cf257557a
Parents: 30f9d7f
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Fri Jan 29 16:23:27 2016 -0500
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Fri Jan 29 16:23:27 2016 -0500

----------------------------------------------------------------------
 app/controllers/ApplicationController.php | 35 +++++++++++++++-----------
 app/libraries/AppUtilities.php            | 23 +++++++++++++++++
 2 files changed, 44 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/93c1b32a/app/controllers/ApplicationController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ApplicationController.php b/app/controllers/ApplicationController.php
index c111141..438ab15 100644
--- a/app/controllers/ApplicationController.php
+++ b/app/controllers/ApplicationController.php
@@ -39,25 +39,32 @@ class ApplicationController extends BaseController {
 
 	public function deleteAppModule()
 	{
+        
         $this->beforeFilter('verifyeditadmin');
         $data = AppUtilities::getAppInterfaceData();
-        foreach($data["appInterfaces"] as $appInterface){
-            foreach($appInterface->applicationModules as $appModule){
-                if($appModule == Input::get("appModuleId")){
-                    $errorMessage = "The selected app module is already assigned to " . $appInterface->applicationName
-                    . " interface. Hence it cannot be removed";
-                    return Redirect::to("app/module")->with("errorMessage", $errorMessage);
-                }
-            }
+        $connections = AppUtilities::checkAppModuleConnections( Input::get("appModuleId"));
+        if( count( $connections["appInterfaces"]) > 0 || count( $connections["appDeployments"]) > 0)
+        {	
+        	$message = "App Module you are trying to delete is connected to - <br/>";
+        	foreach( $connections["appInterfaces"] as $index => $interface)
+        	{
+        		$message .= "Interface " . ($index + 1) . " : " . $interface . "<br/>";
+        	}
+        	foreach( $connections["appDeployments"] as $index => $deployment)
+        	{
+        		$message .= "Deployment " . ($index + 1) . " : " . $deployment . "<br/>";
+        	}
+        	$message .= "<br/>Please disconnect it from all the above interfaces and deployments to be able to delete it.";
+        	return Redirect::to("app/module")->with("errorMessage", $message);
         }
-
-		if( AppUtilities::deleteAppModule( Input::get("appModuleId") ) )
-			$message = "Module has been deleted successfully!";
-		else
-			$message = "An error has occurred. Please report the issue.";
+        else{
+			if( AppUtilities::deleteAppModule( Input::get("appModuleId") ) )
+				$message = "Module has been deleted successfully!";
+			else
+				$message = "An error has occurred. Please report the issue.";
+		}
 
 		return Redirect::to("app/module")->with("message", $message);
-
 	}
 
 	public function showAppInterfaceView()

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/93c1b32a/app/libraries/AppUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AppUtilities.php b/app/libraries/AppUtilities.php
index 3b3102d..f4cd6c4 100644
--- a/app/libraries/AppUtilities.php
+++ b/app/libraries/AppUtilities.php
@@ -253,6 +253,29 @@ class AppUtilities
         return Airavata::getAllAppModules(Session::get('authz-token'), Session::get("gateway_id"));
     }
 
+    public static function checkAppModuleConnections( $appModuleId){
+        $appInterfaces = Airavata::getAllApplicationInterfaces( Session::get('authz-token'), Session::get("gateway_id"));
+        $appDeployments = Airavata::getAllApplicationDeployments( Session::get('authz-token'), Session::get("gateway_id"));
+        $connections = array();
+        $connections["appInterfaces"] = array(); 
+        $connections["appDeployments"] = array();
+
+        foreach($appInterfaces as $appInterface){
+            foreach($appInterface->applicationModules as $appModule){
+                var_dump( $appModule);
+                if($appModule == $appModuleId){
+                    $connections["appInterfaces"][] = $appInterface->applicationName;
+                }
+            }
+        }
+        foreach($appDeployments as $appDeployment){
+            if($appDeployment->appModuleId == $appModuleId){
+                $connections["appDeployments"][] = $appDeployment->appDeploymentId;
+            }
+        }
+        return $connections;
+    }
+
     /**
      * Get all available applications
      * @return null