Package org.apache.airavata.persistance.registry.jpa.utils

Examples of org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator


    /**
     * @param configkey
     * @param configValue
     */
    public static void removeConfiguration(String configkey, String configValue) {
        QueryGenerator queryGenerator = new QueryGenerator(AbstractResource.CONFIGURATION);
        queryGenerator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_KEY, configkey);
        queryGenerator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_VAL, configValue);
        if(isConfigurationExists(configkey, configValue)){
            EntityManager em = getEntityManager();
            em.getTransaction().begin();
            Query q = queryGenerator.deleteQuery(em);
            q.executeUpdate();
            em.getTransaction().commit();
            em.close();
        }
    }
View Full Code Here


    /**
     * @param configkey
     */
    public static void removeConfiguration(String configkey) {
        QueryGenerator queryGenerator = new QueryGenerator(AbstractResource.CONFIGURATION);
        queryGenerator.setParameter(AbstractResource.ConfigurationConstants.CONFIG_KEY, configkey);
        if(isConfigurationExist(configkey)){
            EntityManager em = getEntityManager();
            em.getTransaction().begin();
            Query q = queryGenerator.deleteQuery(em);
            q.executeUpdate();
            em.getTransaction().commit();
            em.close();
        }
    }
View Full Code Here

     */
    public List<Resource> populate(Object[] keys) {
        List<Resource> list = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator = new QueryGenerator(HOST_DESCRIPTOR);
        generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, keys [0]);
        generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, keys[1]);
        Query q = generator.selectQuery(em);
        Host_Descriptor hostDescriptor = (Host_Descriptor)q.getSingleResult();
        HostDescriptorResource hostDescriptorResource =
                (HostDescriptorResource)Utils.getResource(ResourceType.HOST_DESCRIPTOR, hostDescriptor);
        em.getTransaction().commit();
        em.close();
View Full Code Here

    public List<Resource> get(ResourceType type) {
        List<Resource> resourceList = new ArrayList<Resource>();
        if (type == ResourceType.APPLICATION_DESCRIPTOR) {
            EntityManager em = ResourceUtils.getEntityManager();
            em.getTransaction().begin();
            QueryGenerator generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
            generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
            generator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, getHostDescName());
            Query q = generator.selectQuery(em);
            List results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    Application_Descriptor applicationDescriptor = (Application_Descriptor) result;
                    ApplicationDescriptorResource applicationDescriptorResource =
View Full Code Here

     */
    public List<Resource> populate(Object[] keys) {
        List<Resource> list = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator queryGenerator = new QueryGenerator(CONFIGURATION);
        queryGenerator.setParameter(ConfigurationConstants.CONFIG_KEY, keys[0]);
        Query q = queryGenerator.selectQuery(em);
        List resultList = q.getResultList();
        if (resultList.size() != 0) {
            for (Object result : resultList) {
                Configuration configuration = (Configuration) result;
                ConfigurationResource configurationResource =
View Full Code Here

     */
    public void remove(ResourceType type, Object name) {
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        if (type == ResourceType.EXPERIMENT) {
          QueryGenerator generator = new QueryGenerator(EXPERIMENT);
          generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
          Query q = generator.deleteQuery(em);
          q.executeUpdate();
        }else {
            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
            throw new IllegalArgumentException("Unsupported resource type for project resource.");
        }
View Full Code Here

     */
    public Resource get(ResourceType type, Object name) {
        if (type == ResourceType.EXPERIMENT) {
            EntityManager em = ResourceUtils.getEntityManager();
            em.getTransaction().begin();
          QueryGenerator generator = new QueryGenerator(EXPERIMENT);
//          generator.setParameter(ExperimentConstants.PROJECT_NAME, name);
//          generator.setParameter(ExperimentConstants.USERNAME, getWorker().getUser());
          generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
          Query q = generator.selectQuery(em);
            Experiment experiment = (Experiment) q.getSingleResult();
            ExperimentResource experimentResource = (ExperimentResource)
                    Utils.getResource(ResourceType.EXPERIMENT, experiment);
            em.getTransaction().commit();
            em.close();
View Full Code Here

     */
    public List<Resource> populate(Object[] keys) {
        List<Resource> list = new ArrayList<Resource>();
        EntityManager em = ResourceUtils.getEntityManager();
        em.getTransaction().begin();
        QueryGenerator queryGenerator = new QueryGenerator(PROJECT);
        queryGenerator.setParameter(ProjectConstants.PROJECT_NAME, keys[0]);
        Query q = queryGenerator.selectQuery(em);
        List<?> resultList = q.getResultList();
        if (resultList.size() != 0) {
            for (Object result : resultList) {
                Project project = (Project) result;
                ProjectResource projectResource = (ProjectResource)
View Full Code Here

        List<Resource> resourceList = new ArrayList<Resource>();

        if (type == ResourceType.EXPERIMENT) {
            EntityManager em = ResourceUtils.getEntityManager();
            em.getTransaction().begin();
          QueryGenerator generator = new QueryGenerator(EXPERIMENT);
          generator.setParameter(ExperimentConstants.PROJECT_NAME, name);
          Query q = generator.selectQuery(em);
            List<?> results = q.getResultList();
            if (results.size() != 0) {
                for (Object result : results) {
                    Experiment experiment = (Experiment) result;
                    ExperimentResource experimentResource = (ExperimentResource)
View Full Code Here

     */
    public static boolean isGatewayExist(String gatewayName) {

        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        QueryGenerator generator = new QueryGenerator(AbstractResource.GATEWAY);
        generator.setParameter(AbstractResource.GatewayConstants.GATEWAY_NAME, gatewayName);
        Query q = generator.selectQuery(em);
        Gateway gateway = (Gateway) q.getSingleResult();
        em.getTransaction().commit();
        em.close();
        return gateway != null;
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator

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.