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

Examples of org.apache.airavata.persistance.registry.jpa.resources.WorkerResource


    public void addHostDescriptor(HostDescription descriptor) throws RegistryException {
        if (descriptorRegistry != null){
            descriptorRegistry.addHostDescriptor(descriptor);
        } else {
            GatewayResource gateway = jpa.getGateway();
            WorkerResource workerResource = jpa.getWorker();
            String hostName = descriptor.getType().getHostName();
            if (isHostDescriptorExists(hostName)){
                throw new DescriptorAlreadyExistsException(hostName);
            }
            HostDescriptorResource hostDescriptorResource = gateway.createHostDescriptorResource(hostName);
            hostDescriptorResource.setUserName(workerResource.getUser());
            hostDescriptorResource.setContent(descriptor.toXML());
            hostDescriptorResource.save();
        }
    }
View Full Code Here


    public void addServiceDescriptor(ServiceDescription descriptor) throws RegistryException {
        if (descriptorRegistry != null) {
            descriptorRegistry.addServiceDescriptor(descriptor);
        }else {
            GatewayResource gateway = jpa.getGateway();
            WorkerResource workerResource = jpa.getWorker();
            String serviceName = descriptor.getType().getName();
            if (isServiceDescriptorExists(serviceName)){
                throw new DescriptorAlreadyExistsException(serviceName);
            }
            ServiceDescriptorResource serviceDescriptorResource = gateway.createServiceDescriptorResource(serviceName);
            serviceDescriptorResource.setUserName(workerResource.getUser());
            serviceDescriptorResource.setContent(descriptor.toXML());
            serviceDescriptorResource.save();
        }
    }
View Full Code Here

        else {
            if (serviceName==null || hostName==null){
                throw new InsufficientDataException("Service name or Host name cannot be null");
            }
            GatewayResource gateway = jpa.getGateway();
            WorkerResource workerResource = jpa.getWorker();
            String applicationName = descriptor.getType().getApplicationName().getStringValue();
            applicationName = createAppName(serviceName, hostName, applicationName);
            if (isApplicationDescriptorExists(serviceName,hostName,descriptor.getType().getApplicationName().getStringValue())){
                throw new DescriptorAlreadyExistsException(applicationName);
            }
            ApplicationDescriptorResource applicationDescriptorResource = gateway.createApplicationDescriptorResource(applicationName);
            applicationDescriptorResource.setUpdatedUser(workerResource.getUser());
            applicationDescriptorResource.setServiceDescName(serviceName);
            applicationDescriptorResource.setHostDescName(hostName);
            applicationDescriptorResource.setContent(descriptor.toXML());
            applicationDescriptorResource.save();
        }
View Full Code Here

    public void addWorkspaceProject(WorkspaceProject project) throws RegistryException {
        if (projectsRegistry != null){
            projectsRegistry.addWorkspaceProject(project);
        } else {
            WorkerResource worker = jpa.getWorker();
            if (isWorkspaceProjectExists(project.getProjectName())){
                throw new WorkspaceProjectAlreadyExistsException(createProjName(project.getProjectName()));
            }
            ProjectResource projectResource = worker.createProject(createProjName(project.getProjectName()));
            projectResource.save();
        }
    }
View Full Code Here

    public void updateWorkspaceProject(WorkspaceProject project) throws RegistryException {
        if (projectsRegistry != null){
            projectsRegistry.updateWorkspaceProject(project);
        }else {
            WorkerResource worker = jpa.getWorker();
            if (!isWorkspaceProjectExists(project.getProjectName())){
                throw new WorkspaceProjectDoesNotExistsException(createProjName(project.getProjectName()));
            }
            ProjectResource projectResource = worker.getProject(createProjName(project.getProjectName()));
            projectResource.save();
        }
    }
View Full Code Here

    public void deleteWorkspaceProject(String projectName) throws RegistryException {
        if (projectsRegistry != null){
            projectsRegistry.deleteWorkspaceProject(projectName);
        }else {
            WorkerResource worker = jpa.getWorker();
            if (!isWorkspaceProjectExists(projectName)){
                throw new WorkspaceProjectDoesNotExistsException(createProjName(projectName));
            }
            worker.removeProject(createProjName(projectName));
        }
    }
View Full Code Here

    public WorkspaceProject getWorkspaceProject(String projectName) throws RegistryException {
        if (projectsRegistry != null){
            return projectsRegistry.getWorkspaceProject(projectName);
        }
      WorkerResource worker = jpa.getWorker();
    if (!isWorkspaceProjectExists(projectName)){
          throw new WorkspaceProjectDoesNotExistsException(createProjName(projectName));
        }
    ProjectResource projectResource = worker.getProject(createProjName(projectName));
    return new WorkspaceProject(getProjName(projectResource.getName()), this);
    }
View Full Code Here

    public List<WorkspaceProject> getWorkspaceProjects() throws RegistryException{
        if (projectsRegistry != null){
            return projectsRegistry.getWorkspaceProjects();
        }
      WorkerResource worker = jpa.getWorker();
      List<WorkspaceProject> projects=new ArrayList<WorkspaceProject>();
      List<ProjectResource> projectResouces = worker.getProjects();
      for (ProjectResource resource : projectResouces) {
      projects.add(new WorkspaceProject(getProjName(resource.getName()), this));
    }
      return projects;
    }
View Full Code Here

    public void removeExperiment(String experimentId) throws ExperimentDoesNotExistsException {
        if (projectsRegistry != null){
            projectsRegistry.removeExperiment(experimentId);
        }else {
            WorkerResource worker = jpa.getWorker();
            if (!worker.isExperimentExists(experimentId)){
                throw new ExperimentDoesNotExistsException(experimentId);
            }
            worker.removeExperiment(experimentId);
        }
    }
View Full Code Here

    public List<AiravataExperiment> getExperiments() throws RegistryException{
        if (projectsRegistry != null){
            return projectsRegistry.getExperiments();
        }
        WorkerResource worker = jpa.getWorker();
      List<AiravataExperiment> result=new ArrayList<AiravataExperiment>();
      List<ExperimentResource> experiments = worker.getExperiments();
      for (ExperimentResource resource : experiments) {
      AiravataExperiment e = createAiravataExperimentObj(resource);
      result.add(e);
    }
        return result;
View Full Code Here

TOP

Related Classes of org.apache.airavata.persistance.registry.jpa.resources.WorkerResource

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.