Package org.apache.aiaravata.application.catalog.data.model

Examples of org.apache.aiaravata.application.catalog.data.model.ComputeResourcePreference


        }

        EntityManager em = null;
        try {
            em = AppCatalogJPAUtils.getEntityManager();
            ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class,
                    new ComputeResourcePreferencePK(ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID),
                            ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID)));
            em.close();
            return existingPreference != null;
        }catch (Exception e) {
View Full Code Here


            em.getTransaction().begin();
            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
            generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID));
            generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID));
            Query q = generator.selectQuery(em);
            ComputeResourcePreference preference = (ComputeResourcePreference) q.getSingleResult();
            ComputeHostPreferenceResource preferenceResource =
                    (ComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
            em.getTransaction().commit();
            em.close();
            return preferenceResource;
View Full Code Here

                generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, value);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ComputeResourcePreference preference = (ComputeResourcePreference) result;
                        if (preference.getComputeHostResource()!=null) {
              ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource) AppCatalogJPAUtils
                  .getResource(
                      AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
                      preference);
              preferenceResourceList.add(preferenceResource);
            }
                    }
                }
            } else if (fieldName.equals(ComputeResourcePreferenceConstants.GATEWAY_ID)) {
                generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, value);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ComputeResourcePreference preference = (ComputeResourcePreference) result;
                        if (preference.getComputeHostResource()!=null) {
                          ComputeHostPreferenceResource preferenceResource =
                                  (ComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
                          preferenceResourceList.add(preferenceResource);
                        }
                    }
                }
            } else if (fieldName.equals(ComputeResourcePreferenceConstants.PREFERED_JOB_SUB_PROTOCOL)) {
                generator.setParameter(ComputeResourcePreferenceConstants.PREFERED_JOB_SUB_PROTOCOL, value);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ComputeResourcePreference preference = (ComputeResourcePreference) result;
                        if (preference.getComputeHostResource()!=null) {
              ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource) AppCatalogJPAUtils
                  .getResource(
                      AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
                      preference);
              preferenceResourceList.add(preferenceResource);
            }
                    }
                }
            } else if (fieldName.equals(ComputeResourcePreferenceConstants.PREFERED_DATA_MOVE_PROTOCOL)) {
                generator.setParameter(ComputeResourcePreferenceConstants.PREFERED_DATA_MOVE_PROTOCOL, value);
                q = generator.selectQuery(em);
                results = q.getResultList();
                if (results.size() != 0) {
                    for (Object result : results) {
                        ComputeResourcePreference preference = (ComputeResourcePreference) result;
                        if (preference.getResourceId()!=null) {
              ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource) AppCatalogJPAUtils
                  .getResource(
                      AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
                      preference);
              preferenceResourceList.add(preferenceResource);
View Full Code Here

    @Override
    public void save() throws AppCatalogException {
        EntityManager em = null;
        try {
            em = AppCatalogJPAUtils.getEntityManager();
            ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class, new ComputeResourcePreferencePK(gatewayId, resourceId));
            em.close();

            em = AppCatalogJPAUtils.getEntityManager();
            em.getTransaction().begin();
            ComputeResource computeResource = em.find(ComputeResource.class, resourceId);
            GatewayProfile gatewayProf = em.find(GatewayProfile.class, gatewayId);
            if (existingPreference != null) {
                existingPreference.setResourceId(resourceId);
                existingPreference.setGatewayId(gatewayId);
                existingPreference.setComputeHostResource(computeResource);
                existingPreference.setGatewayProfile(gatewayProf);
                existingPreference.setOverrideByAiravata(overrideByAiravata);
                existingPreference.setPreferedJobSubmissionProtocol(preferredJobProtocol);
                existingPreference.setPreferedDataMoveProtocol(preferedDMProtocol);
                existingPreference.setScratchLocation(scratchLocation);
                existingPreference.setProjectNumber(projectNumber);
                existingPreference.setBatchQueue(batchQueue);
                em.merge(existingPreference);
            } else {
                ComputeResourcePreference resourcePreference = new ComputeResourcePreference();
                resourcePreference.setResourceId(resourceId);
                resourcePreference.setGatewayId(gatewayId);
                resourcePreference.setComputeHostResource(computeResource);
                resourcePreference.setGatewayProfile(gatewayProf);
                resourcePreference.setOverrideByAiravata(overrideByAiravata);
                resourcePreference.setPreferedJobSubmissionProtocol(preferredJobProtocol);
                resourcePreference.setPreferedDataMoveProtocol(preferedDMProtocol);
                resourcePreference.setScratchLocation(scratchLocation);
                resourcePreference.setProjectNumber(projectNumber);
                resourcePreference.setBatchQueue(batchQueue);
                em.persist(resourcePreference);
            }
            em.getTransaction().commit();
            em.close();
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.aiaravata.application.catalog.data.model.ComputeResourcePreference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.