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

fUML.Semantics.Activities.CompleteActivities.DataStoreNodeActivation Maven / Gradle / Ivy

Go to download

This open source software is a reference implementation, consisting of software and related files, for the OMG specification called the Semantics of a Foundational Subset for Executable UML Models (fUML). The reference implementation is intended to implement the execution semantics of UML activity models, accepting an XMI file from a conformant UML model as its input and providing an execution trace of the selected activity model(s) as its output. The core execution engine, which is directly generated from the normative syntactic and semantic models for fUML, may also be used as a library implementation of fUML in other software.

There is a newer version: 1.5.0a
Show newest version
/*
 * Copyright 2017 Data Access Technologies, Inc. (Model Driven Solutions)
 *
 * Licensed under the Academic Free License version 3.0 
 * (http://www.opensource.org/licenses/afl-3.0.php), except as stated 
 * in the file entitled Licensing-Information. 
 */

package fUML.Semantics.Activities.CompleteActivities;

import fUML.Semantics.Activities.IntermediateActivities.CentralBufferNodeActivation;
import fUML.Semantics.Activities.IntermediateActivities.Token;
import fUML.Semantics.Activities.IntermediateActivities.TokenList;
import fUML.Semantics.Classes.Kernel.Value;

public class DataStoreNodeActivation extends CentralBufferNodeActivation {

	@Override
	public void addToken(Token token) {
		// Add the given token to the data store only if it is unique,
		// that is, if its value is not the same as the value of
		// another token already held in the data store.
		
		Value value = token.getValue();
		
		boolean isUnique = true;
		if (value != null) {
			TokenList heldTokens = this.getTokens();
			int i = 1;
			while (isUnique & i <= heldTokens.size()) {
				isUnique = !heldTokens.getValue(i-1).getValue().equals(value);
				i = i + 1;
			}
		}
		
		if (isUnique) {
			super.addToken(token);
		}
		
	}
	
	@Override
	public int removeToken(Token token) {
		// Remove the given token from the data store, but then immediately 
		// add a copy back into the data store and offer it (unless the
		// node activation has already been terminated).
		
		int i = super.removeToken(token);
		
		if (this.isRunning()) {
			super.addToken(token.copy());
			this.sendUnofferedTokens();
		}
		
		return i;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy