All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.whitesource.agent.api.dispatch.CheckPoliciesResult Maven / Gradle / Ivy

There is a newer version: 18.4.1
Show newest version
/**
 * Copyright (C) 2012 White Source Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.whitesource.agent.api.dispatch;

import org.whitesource.agent.api.model.PolicyCheckResourceNode;
import org.whitesource.agent.api.model.ResourceInfo;

import java.io.Serializable;
import java.util.*;


/**
 * Result of the check policies operation.
 * 
 * @author Edo.Shor
 *
 * @since 1.2.0
 */
public class CheckPoliciesResult implements Serializable {

    /* --- Static members --- */

    private static final long serialVersionUID = 7083481460957821913L;

	/* --- Members --- */

    /**
     * Name of organization in.
     */
	private String organization;

    /**
     * Map of project name to the root of its dependency graph with policies application result.
     */
	private Map existingProjects;

    /**
     * Map of project name to the root of its dependency graph with policies application result.
     */
	private Map newProjects;

    /**
     * Map of project name to its set of new resources to insert into inventory.
     */
    private Map> projectNewResources;

	/* --- Constructors --- */

	/**
	 * Default constructor
	 */
	public CheckPoliciesResult() {
		existingProjects = new HashMap();
        newProjects = new HashMap();
        projectNewResources = new HashMap>();
	}

	/**
	 * Constructor
	 *
	 * @param organization Name of the domain.
	 */
	public CheckPoliciesResult(String organization) {
		this();
		this.organization = organization;
	}

    /* --- Public methods --- */

    /**
     * @return True if some project in this result have some rejected dependency.
     */
    public boolean hasRejections() {
        boolean hasRejections = false;

        Collection roots = new ArrayList();
        roots.addAll(getExistingProjects().values());
        roots.addAll(getNewProjects().values());

        Iterator iterator = roots.iterator();
        while (iterator.hasNext() && !hasRejections ) {
            hasRejections = iterator.next().hasRejections();
        }        

        return hasRejections;
    }

	/* --- Getters / Setters --- */ 

	public String getOrganization() {
		return organization;
	}

	public void setOrganization(String organization) {
		this.organization = organization;
	}

    public Map getNewProjects() {
        return newProjects;
    }

    public void setNewProjects(Map newProjects) {
        this.newProjects = newProjects;
    }

    public Map getExistingProjects() {
        return existingProjects;
    }

    public void setExistingProjects(Map existingProjects) {
        this.existingProjects = existingProjects;
    }

    public Map> getProjectNewResources() {
        return projectNewResources;
    }

    public void setProjectNewResources(Map> projectNewResources) {
        this.projectNewResources = projectNewResources;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy