<commit_before>/**
 * 
 */
package com.bearingpoint.opencms.workflow2.stage;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsUser;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.util.CmsUUID;

import com.bearingpoint.opencms.commons.springmanager.SpringManager;
import com.bearingpoint.opencms.workflow2.WorkflowException;
import com.bearingpoint.opencms.workflow2.cms.CmsMirPrBelongsToOtherInvisible;
import com.bearingpoint.opencms.workflow2.stage.dao.I_WorkflowProjectListDAO;
import com.bearingpoint.opencms.workflow2.stage.domain.WorkflowProject;

/**
 * ProjectManager
 * <p>
 * Manages the workflow nodes defined as OpenCms projects.
 * Returns valid target projects for given resource states.
 * <p>
 * 
 * @author David.Trattnig
 */
public class ProjectManager implements I_ProjectManager {

	private static final String SPRING_PROJECTMANAGER_DAO = "workflow.workflowProjectDAO";


	private static I_WorkflowProjectListDAO _dao;
	private CmsObject _cms;
		
	private static final Log LOG = CmsLog.getLog(ProjectManager.class);
	
	/**
	 * Constructor which initializes the project manager
	 * with the CmsObject and the workflow engine.
	 * <p>
	 * @param engine
	 */
	public ProjectManager(CmsObject cms) {
		
		_cms = cms;
		_dao = (I_WorkflowProjectListDAO) SpringManager.getBean(SPRING_PROJECTMANAGER_DAO);		
	}
	
	/**
	 * If you use this constructor you have to call
	 * <code>setCmsObject(CmsObject cms)</code> and
	 * <code>initDaoObjects()</code>
	 * afterwards. otherwise most operations will fail.
	 */
	public ProjectManager() {}

	/**
	 * Initializes the cms object.
	 * <p>
	 * @param cms
	 */
	public void setCmsObject(CmsObject cms) {
		this._cms = cms;
	}
	
	/* (non-Javadoc)
	 * @see com.bearingpoint.opencms.workflow2.stage.I_ProjectManager#getAllWorkflowProjects()
	 */
	public List<ProjectWrapper> getAllWorkflowProjects() throws WorkflowException {

		List<CmsProject> allProjects = null;
		List<ProjectWrapper> matchingProjects = new ArrayList<ProjectWrapper>();
		List<WorkflowProject> projectWorkflow;
		
		try {
			projectWorkflow = _dao.retrieveAllWorkflowProjects();
		} catch (NoProjectsAvailableException e1) {
			return new ArrayList();
		}
		
		if (projectWorkflow == null || projectWorkflow.size()<=0) {
			return new ArrayList();
		}
		
		try {
			allProjects = _cms.getAllManageableProjects();
		} catch (CmsException e) {
			throw new WorkflowException("error while reading all CMS projects", e);
		}
		
		boolean foundMatchingProject;
		for (WorkflowProject wfProject : projectWorkflow) {

			foundMatchingProject=false;<commit_msg>renamed utility method for AdminCmsObject retrieval<commit_after>/**
 * 
 */
package com.bearingpoint.opencms.workflow2.stage;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsUser;
import org.opencms.main.CmsException;
import org.opencms.main.CmsLog;
import org.opencms.util.CmsUUID;

import com.bearingpoint.opencms.commons.springmanager.SpringManager;
import com.bearingpoint.opencms.workflow2.WorkflowException;
import com.bearingpoint.opencms.workflow2.cms.CmsMirPrBelongsToOtherInvisible;
import com.bearingpoint.opencms.workflow2.cms.CmsUtil;
import com.bearingpoint.opencms.workflow2.stage.dao.I_WorkflowProjectListDAO;
import com.bearingpoint.opencms.workflow2.stage.domain.WorkflowProject;

/**
 * ProjectManager
 * <p>
 * Manages the workflow nodes defined as OpenCms projects.
 * Returns valid target projects for given resource states.
 * <p>
 * 
 * @author David.Trattnig
 */
public class ProjectManager implements I_ProjectManager {

	private static final String SPRING_PROJECTMANAGER_DAO = "workflow.workflowProjectDAO";


	private static I_WorkflowProjectListDAO _dao;
	private CmsObject _cms;
		
	private static final Log LOG = CmsLog.getLog(ProjectManager.class);
	
	/**
	 * Constructor which initializes the project manager
	 * with the CmsObject and the workflow engine.
	 * <p>
	 * @param engine
	 */
	public ProjectManager(CmsObject cms) {
		
		_cms = cms;
		_dao = (I_WorkflowProjectListDAO) SpringManager.getBean(SPRING_PROJECTMANAGER_DAO);		
	}
	
	/**
	 * If you use this constructor you have to call
	 * <code>setCmsObject(CmsObject cms)</code> and
	 * <code>initDaoObjects()</code>
	 * afterwards. otherwise most operations will fail.
	 */
	public ProjectManager() {}

	/**
	 * Initializes the cms object.
	 * <p>
	 * @param cms
	 */
	public void setCmsObject(CmsObject cms) {
		this._cms = cms;
	}
	
	/* (non-Javadoc)
	 * @see com.bearingpoint.opencms.workflow2.stage.I_ProjectManager#getAllWorkflowProjects()
	 */
	public List<ProjectWrapper> getAllWorkflowProjects() throws WorkflowException {

		List<CmsProject> allProjects = null;
		List<ProjectWrapper> matchingProjects = new ArrayList<ProjectWrapper>();
		List<WorkflowProject> projectWorkflow;
		
		try {
			projectWorkflow = _dao.retrieveAllWorkflowProjects();
		} catch (NoProjectsAvailableException e1) {
			return new ArrayList();
		}
		
		if (projectWorkflow == null || projectWorkflow.size()<=0) {
			return new ArrayList();
		}
		
		try { 
			allProjects = CmsUtil.getAdminCmsObject().getAllManageableProjects();
			
		} catch (CmsException e) {
			throw new WorkflowException("error while reading all CMS projects", e);
		}
		
		boolean foundMatchingProject;
		for (WorkflowProject wfProject : projectWorkflow) {

			foundMatchingProject=false;
{'fraction_non_alphanumeric': 0.10084760422072306, 'fraction_numerical': 0.002940667704549386, 'mean_word_length': 4.741807348560079, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7489769', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1862, 'n_words': 392}