Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 Michael Ruflin, Andr´┐Ż Locher, Claudia von Bastian. This file is part of Tatool. Tatool is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Tatool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Tatool. If not, see <http://www.gnu.org/licenses/>. /
 
 package ch.tatool.app.service.exec.impl;
 
 
 
Main execution data holder object. Manages the root elements, the current element stack (including switching from one to the next), the pause durations, etc.

Author(s):
Michael Ruflin
 
 public class ExecutionDataImpl implements ExecutionData {
 	
 	Logger logger = LoggerFactory.getLogger(ExecutionDataImpl.class);

Data service used to store new data.
 
 	private DataService dataService;

    
Flag that holds whether the session is requested to be closed.
 
     private boolean closeCurrentSession;
     
     // actual execution data
     
Module object - always available.
 
 	private Module module;

Session object.
 
Trial object.
 
 	private LinkedList<Trialtrials;

Create a new ExecutionDataImpl object.
 
 	public ExecutionDataImpl() {
 		 = new LinkedList<Trial>();
 	}
 	
 	public void setDataService(DataService dataService) {
 		this. = dataService;
 	}

Opens a session if no session is opened currently

Returns:
true if a new session was opened
 
 	public boolean openSession() {
         // return if we already got a session
 		if ( != nullreturn false;
 		
     	// create a module session
     	 = false;
     	return true;
 	}
 	
 	public void setSessionCompleted(int completed) {
 	}
 	
 	public int getSessionCompleted() {
 	}

Returns whether a session is closable.

Returns:
true if a session is available and its closing has been requested
 
 	public boolean isCloseSessionRequested() {
 		// must have a session and closing requested
 		return  &&  != null;
 	}

Closes and clears a session.
	public void closeSession() {
		if ( != null) {
	        // save/finish the session
	        .saveModule();
	        
	         = null;
	         = false;
else {
			.warn("Closing nonexisting session - should never happen!");
		}
	}

Persists the current trials and removes them from the data object.
	public void persistTrials() {
        for (Trial t : ) {
        }
        
        // save the session and the module, as both or either might have been updated
        .saveModule();
        
        // do some cleanup
        .clear();
	}
	public void setModule(Module module) {
		this. = module;
	}
	// clearing
Clears the execution data object.
	public void clear() {
		 = null;
		 = null;
	}
	public boolean isCloseCurrentSession() {
	}
	public void setCloseCurrentSession(boolean closeCurrentSession) {
		this. = closeCurrentSession;
	}
	// ExecutionData
	public Module getModule() {
		return ;
	}
	}
	public void markSessionEnd() {
	}
		if (.isEmpty()) {
			return addTrial();
else {
			return .getFirst();
		}
	}
		if (.isEmpty()) {
			return addTrial();
else {
			return .getLast();
		}
	}
	public LinkedList<TrialgetTrials() {
		return ;
	}
	public Trial addTrial() {
		TrialImpl trial = new TrialImpl();
		addTrial(trial);
		return trial;
	}
	private void addTrial(Trial trial) {
		if ( == null) {
			 = new LinkedList<Trial>();
		}
		.add(trial);
	}
New to GrepCode? Check out our FAQ X