blob: a828a9c4f288955ed16b50d692d1bacc62788a55 [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2019 Robert Bosch GmbH and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
* *******************************************************************************
*/
package templates.m2m.utils
import org.eclipse.app4mc.amalthea.model.AbstractEventChain
import org.eclipse.app4mc.amalthea.model.Event
import org.eclipse.app4mc.amalthea.model.ProcessEvent
import org.eclipse.app4mc.amalthea.model.RunnableEvent
import templates.AbstractAmaltheaInchronTransformer
import templates.utils.AmltCacheModel
class EventSequenceUtils extends AbstractAmaltheaInchronTransformer{
static def boolean testConditionEventChain2EventSequence(AbstractEventChain abstractEventChain){
if (abstractEventChain.stimulus === null) return false
if (abstractEventChain.response === null) return false
val stimulusOk = testConditionTraceEvent(abstractEventChain.stimulus)
val responseOk = testConditionTraceEvent(abstractEventChain.response)
return stimulusOk && responseOk
}
static def dispatch boolean testConditionTraceEvent(Event event){
return false
}
static def dispatch boolean testConditionTraceEvent(RunnableEvent event){
if (event?.process!==null && event?.entity!==null){
val AmltCacheModel cacheModel = customObjsStore.getInstance(AmltCacheModel)
if (cacheModel.getInchronComponent(event.process) !== null){
return true
}
}
return false
}
static def dispatch boolean testConditionTraceEvent(ProcessEvent event){
if (event?.entity !== null){
val AmltCacheModel cacheModel = customObjsStore.getInstance(AmltCacheModel)
if (cacheModel.getInchronComponent(event.entity) !== null){
return true
}
}
return false
}
}