Search in sources :

Example 1 with ApplicationInterface

use of org.apache.airavata.registry.cpi.ApplicationInterface in project airavata by apache.

the class WorkflowUtils method getExecutionType.

public static ExecutionType getExecutionType(Experiment experiment) {
    try {
        ApplicationInterface applicationInterface = RegistryFactory.getAppCatalog().getApplicationInterface();
        List<String> allApplicationInterfaceIds = applicationInterface.getAllApplicationInterfaceIds();
        String applicationId = experiment.getApplicationId();
        if (allApplicationInterfaceIds.contains(applicationId)) {
            return ExecutionType.SINGLE_APP;
        } else {
            List<String> allWorkflows = WorkflowCatalogFactory.getWorkflowCatalog().getAllWorkflows(ServerSettings.getDefaultUserGateway());
            if (allWorkflows.contains(applicationId)) {
                return ExecutionType.WORKFLOW;
            }
        }
    } catch (AppCatalogException e) {
        logger.error(e.getMessage(), e);
    } catch (ApplicationSettingsException e) {
        logger.error(e.getMessage(), e);
    }
    return ExecutionType.UNKNOWN;
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationInterface(org.apache.airavata.registry.cpi.ApplicationInterface)

Example 2 with ApplicationInterface

use of org.apache.airavata.registry.cpi.ApplicationInterface in project airavata by apache.

the class OrchestratorUtils method getApplicationInterfaceName.

public static String getApplicationInterfaceName(OrchestratorContext context, ProcessModel model) throws RegistryException {
    try {
        ApplicationInterface applicationInterface = context.getRegistry().getAppCatalog().getApplicationInterface();
        ApplicationInterfaceDescription appInterface = applicationInterface.getApplicationInterface(model.getApplicationInterfaceId());
        return appInterface.getApplicationName();
    } catch (AppCatalogException e) {
        throw new RegistryException("Error while retrieving application interface", e);
    }
}
Also used : ApplicationInterface(org.apache.airavata.registry.cpi.ApplicationInterface) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)

Example 3 with ApplicationInterface

use of org.apache.airavata.registry.cpi.ApplicationInterface in project airavata by apache.

the class AppInterfaceTest method testAppInterface.

@Test
public void testAppInterface() {
    try {
        ApplicationInterface appInterface = appcatalog.getApplicationInterface();
        ApplicationInterfaceDescription description = new ApplicationInterfaceDescription();
        String wrfModuleId = addAppModule("WRF");
        String amberModuleId = addAppModule("AMBER");
        List<String> modules = new ArrayList<String>();
        modules.add(wrfModuleId);
        modules.add(amberModuleId);
        InputDataObjectType appInput1 = createAppInput("input1", "input1", DataType.STRING);
        InputDataObjectType appInput2 = createAppInput("input2", "input2", DataType.INTEGER);
        List<InputDataObjectType> inputs = new ArrayList<InputDataObjectType>();
        inputs.add(appInput1);
        inputs.add(appInput2);
        OutputDataObjectType output1 = createAppOutput("output1", "", DataType.STRING);
        OutputDataObjectType output2 = createAppOutput("output2", "", DataType.STRING);
        List<OutputDataObjectType> outputs = new ArrayList<OutputDataObjectType>();
        outputs.add(output1);
        outputs.add(output2);
        description.setApplicationName("testApplication");
        description.setApplicationDescription("my testApplication");
        description.setApplicationModules(modules);
        description.setApplicationInputs(inputs);
        description.setApplicationOutputs(outputs);
        String appID = appInterface.addApplicationInterface(description, ServerSettings.getDefaultUserGateway());
        System.out.println("********** application id ************* : " + appID);
        ApplicationInterfaceDescription ainterface = null;
        if (appInterface.isApplicationInterfaceExists(appID)) {
            ainterface = appInterface.getApplicationInterface(appID);
            OutputDataObjectType output3 = createAppOutput("output3", "", DataType.STRING);
            OutputDataObjectType output4 = createAppOutput("output4", "", DataType.STRING);
            outputs.add(output3);
            outputs.add(output4);
            ainterface.setApplicationOutputs(outputs);
            appInterface.updateApplicationInterface(appID, ainterface);
            ApplicationInterfaceDescription updateApp = appInterface.getApplicationInterface(appID);
            List<OutputDataObjectType> appOutputs = updateApp.getApplicationOutputs();
            System.out.println("********** application name ************* : " + updateApp.getApplicationName());
            System.out.println("********** application description ************* : " + updateApp.getApplicationDescription());
            System.out.println("********** output size ************* : " + appOutputs.size());
        }
        ApplicationModule wrfModule = appInterface.getApplicationModule(wrfModuleId);
        System.out.println("********** WRF module name ************* : " + wrfModule.getAppModuleName());
        ApplicationModule amberModule = appInterface.getApplicationModule(amberModuleId);
        System.out.println("********** Amber module name ************* : " + amberModule.getAppModuleName());
        List<InputDataObjectType> applicationInputs = appInterface.getApplicationInputs(appID);
        System.out.println("********** App Input size ************* : " + applicationInputs.size());
        List<OutputDataObjectType> applicationOutputs = appInterface.getApplicationOutputs(appID);
        System.out.println("********** App output size ************* : " + applicationOutputs.size());
        description.setApplicationName("testApplication2");
        appInterface.updateApplicationInterface(appID, description);
        if (appInterface.isApplicationInterfaceExists(appID)) {
            ainterface = appInterface.getApplicationInterface(appID);
            System.out.println("********** updated application name ************* : " + ainterface.getApplicationName());
        }
        wrfModule.setAppModuleVersion("1.0.1");
        appInterface.updateApplicationModule(wrfModuleId, wrfModule);
        wrfModule = appInterface.getApplicationModule(wrfModuleId);
        System.out.println("********** Updated WRF module version ************* : " + wrfModule.getAppModuleVersion());
        Map<String, String> filters = new HashMap<String, String>();
        filters.put(AppCatAbstractResource.ApplicationInterfaceConstants.APPLICATION_NAME, "testApplication2");
        List<ApplicationInterfaceDescription> apps = appInterface.getApplicationInterfaces(filters);
        System.out.println("********** Size og app interfaces ************* : " + apps.size());
        List<ApplicationInterfaceDescription> appInts = appInterface.getAllApplicationInterfaces(ServerSettings.getDefaultUserGateway());
        System.out.println("********** Size of all app interfaces ************* : " + appInts.size());
        List<String> appIntIds = appInterface.getAllApplicationInterfaceIds();
        System.out.println("********** Size of all app interface ids ************* : " + appIntIds.size());
        assertTrue("App interface saved successfully", ainterface != null);
    } catch (AppCatalogException e) {
        e.printStackTrace();
    } catch (ApplicationSettingsException e) {
        e.printStackTrace();
    }
}
Also used : ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) HashMap(java.util.HashMap) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) ApplicationInterface(org.apache.airavata.registry.cpi.ApplicationInterface) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) Test(org.junit.Test)

Aggregations

ApplicationInterface (org.apache.airavata.registry.cpi.ApplicationInterface)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)2 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)1 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)1 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)1 Test (org.junit.Test)1