/*
 * Copyright 2011 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php
 *
 * 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.rice.krms.test;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
import org.kuali.rice.core.api.uif.RemotableAttributeError;
import org.kuali.rice.core.api.uif.RemotableAttributeField;
import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter;
import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
import org.kuali.rice.krms.api.repository.action.ActionDefinition;
import org.kuali.rice.krms.framework.engine.Action;
import org.kuali.rice.krms.framework.type.ActionTypeService;

import javax.jws.WebParam;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

/**
 * Used to help test agendas
 * @author gilesp
 *
 */
public class TestActionTypeService implements ActionTypeService, Action {

	private static final Set<String> actionsFired = new HashSet<String>();
	
	public static void resetActionsFired() {
		actionsFired.clear();
	}
	
	public static boolean actionFired(String name) {
		return actionsFired.contains(name);
	}
	
	public TestActionTypeService(String name) {
		this.name = name;
	}
	
	private final String name;
	
	@Override
	public void execute(ExecutionEnvironment environment) {
		actionsFired.add(name);
	}
	
	/**
	 * @see org.kuali.rice.krms.framework.engine.Action#executeSimulation(org.kuali.rice.krms.api.engine.ExecutionEnvironment)
	 */
	@Override
	public void executeSimulation(ExecutionEnvironment environment) {
		throw new UnsupportedOperationException();
	}
	
	public boolean actionFired() {
		return actionFired(name);
	}

    @Override
    public Action loadAction(ActionDefinition actionDefinition) {
        return this;
    }

    @Override
    public List<RemotableAttributeField> getAttributeFields() {
        return Collections.emptyList();
    }

    @Override
    public List<RemotableAttributeError> validateAttributes(@WebParam(name = "attributes") @XmlJavaTypeAdapter(
            value = MapStringStringAdapter.class) Map<String, String> attributes) throws RiceIllegalArgumentException {
        throw new UnsupportedOperationException();
    }

    @Override
    public List<RemotableAttributeError> validateAttributesAgainstExisting(@WebParam(name = "newAttributes") @XmlJavaTypeAdapter(
            value = MapStringStringAdapter.class) Map<String, String> newAttributes, @WebParam(name = "oldAttributes") @XmlJavaTypeAdapter(
            value = MapStringStringAdapter.class) Map<String, String> oldAttributes) throws RiceIllegalArgumentException {
        throw new UnsupportedOperationException();
    }
}

@@ -2427,16 +2427,25 @@
 eFields(
+String id
 ) %7B%0A    
@@ -2565,109 +2565,43 @@
 tes(
-@WebParam(name = %22attributes%22) @XmlJavaTypeAdapter(%0A            value = MapStringStringAdapter.class)
+%0A            String id,%0A           
  Map
@@ -2619,32 +2619,37 @@
 ring%3E attributes
+%0A    
 ) throws RiceIll
@@ -2823,252 +2823,90 @@
 ing(
-@WebParam(name = %22newAttributes%22) @XmlJavaTypeAdapter(%0A            value = MapStringStringAdapter.class) Map%3CString, String%3E newAttributes, @WebParam(name = %22oldAttributes%22) @XmlJavaTypeAdapter(%0A            value = MapStringStringAdapter.class)
+%0A            String id,%0A            Map%3CString, String%3E newAttributes,%0A           
  Map
@@ -2935,16 +2935,21 @@
 tributes
+%0A    
 ) throws

Create PeopleFlowActionTypeService