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

org.tinygroup.flowservicecomponent.CallServiceComponent Maven / Gradle / Ivy

There is a newer version: 3.4.8
Show newest version
/**
 *  Copyright (c) 1997-2013, www.tinygroup.org ([email protected]).
 *
 *  Licensed under the GPL, Version 3.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.gnu.org/licenses/gpl.html
 *
 *  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.tinygroup.flowservicecomponent;

import org.tinygroup.cepcore.CEPCore;
import org.tinygroup.context.Context;
import org.tinygroup.event.Event;
import org.tinygroup.event.ServiceRequest;
import org.tinygroup.flow.ComponentInterface;

import java.util.UUID;

public class CallServiceComponent implements ComponentInterface {

	private String serviceId;
	private String serviceName;
	private String groupId;
	private String artifactId;
	private String version;
	private CEPCore cepCore;
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	public String getArtifactId() {
		return artifactId;
	}

	public void setArtifactId(String artifactId) {
		this.artifactId = artifactId;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getServiceId() {
		return serviceId;
	}

	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public void execute(Context context) {
//		CEPCore cepCore = (CEPCore)SpringBeanContainer.getBean("cepcore");
		Event event = getEvent(context);
		cepCore.process(event);
	}

	private Event getEvent(Context context) {
		Event event = new Event();
		event.setEventId(UUID.randomUUID().toString());
		ServiceRequest serviceRequest = new ServiceRequest();
		serviceRequest.setContext(context);
		if (notNull(serviceId)) {
			serviceRequest.setServiceId(serviceId);
		}
		event.setServiceRequest(serviceRequest);
		return event;
	}

	private boolean notNull(String str) {
		return str != null && !"".equals(str);
	}

	public CEPCore getCepCore() {
		return cepCore;
	}

	public void setCepCore(CEPCore cepCore) {
		this.cepCore = cepCore;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy