<commit_before>package de.fraunhofer.iem.provider

import de.fraunhofer.iem.projectPlanning.Assignment
import de.fraunhofer.iem.projectPlanning.Employee
import de.fraunhofer.iem.projectPlanning.Project
import de.fraunhofer.iem.projectPlanning.ProjectPlan
import de.fraunhofer.iem.projectPlanning.ProjectPlanningFactory
import org.eclipse.emf.common.command.Command
import org.eclipse.emf.ecore.impl.EObjectImpl
import org.eclipse.emf.edit.command.AddCommand
import org.eclipse.emf.edit.command.DeleteCommand
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain
import org.eclipse.emf.edit.domain.EditingDomain
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory
import org.muml.psm.allocation.language.^as.StorageProvider

/**
 * MUML-specific StorageProvider. Currently, only ComponentInstances
 * can be related to StructuredResourceInstances
 */
class ProjectPlanningStorageProvider extends EObjectImpl implements StorageProvider {
	
	private static final String illegalContext = "Got an illegal context: %s"
	private static final String illegalPair = "Unable to store relation: %s to %s"
	
	protected ProjectPlan projectPlan
	protected EditingDomain editingDomain
		 
	override void initialize(Object context) {
		if (!(context instanceof ProjectPlan)) {
			throw new IllegalArgumentException(
				String.format(illegalContext, context)
			)
		}
		projectPlan = context as ProjectPlan
		editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(projectPlan)
			?: WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain
		val Command deleteCommand = DeleteCommand.create(editingDomain,projectPlan.assignments);
 		editingDomain.getCommandStack().execute(deleteCommand);
 		projectPlan  = projectPlan as ProjectPlan
  	}
	
	override store(Object source, Object target) {
		storePair(source, target)
	}
	
	def dispatch ProjectPlan storePair(Object source, Object target) {
		throw new IllegalArgumentException(
			String.format(illegalPair, source, target)
		)
	}
	
	def dispatch ProjectPlan storePair(Project source, Employee target) {
		println("storePair: " + source.name + " -> " + target.name)
		println("editingDomain: " + AdapterFactoryEditingDomain.getEditingDomainFor(projectPlan))
		val Assignment assignment = ProjectPlanningFactory.eINSTANCE.createAssignment()
		assignment.employee = target
		assignment.project = source
	//	val Command deleteCommand = DeleteCommand.create(editingDomain,seminar.assignments);
	//	editingDomain.getCommandStack().execute(deleteCommand);
		
		val Command addCommand = AddCommand.create(editingDomain, projectPlan, projectPlan.assignments ,assignment);
	//	seminar.assignments.add(assignment)
		editingDomain.getCommandStack().execute(addCommand);
	//	val serializer = Guice.createInjector(new SeminarRuntimeModule()).getInstance(Serializer);
	// val String dsl = serializer.serialize(seminar);
		projectPlan.eResource.save(newHashMap())
		println("after save")
		println(projectPlan.assignments)
		projectPlan
	}
	
	
	override noRelationFound() {
		// return empty systemAllocation instance (for now we just do
		// this in order to pass the algorithMain/nonexistentAllocation
		// testcase)
		projectPlan
	}
	
}<commit_msg>Revert "Add another debug statement to the StorageProvider"<commit_after>package de.fraunhofer.iem.provider

import de.fraunhofer.iem.projectPlanning.Assignment
import de.fraunhofer.iem.projectPlanning.Employee
import de.fraunhofer.iem.projectPlanning.Project
import de.fraunhofer.iem.projectPlanning.ProjectPlan
import de.fraunhofer.iem.projectPlanning.ProjectPlanningFactory
import org.eclipse.emf.common.command.Command
import org.eclipse.emf.ecore.impl.EObjectImpl
import org.eclipse.emf.edit.command.AddCommand
import org.eclipse.emf.edit.command.DeleteCommand
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain
import org.eclipse.emf.edit.domain.EditingDomain
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory
import org.muml.psm.allocation.language.^as.StorageProvider

/**
 * MUML-specific StorageProvider. Currently, only ComponentInstances
 * can be related to StructuredResourceInstances
 */
class ProjectPlanningStorageProvider extends EObjectImpl implements StorageProvider {
	
	private static final String illegalContext = "Got an illegal context: %s"
	private static final String illegalPair = "Unable to store relation: %s to %s"
	
	protected ProjectPlan projectPlan
	protected EditingDomain editingDomain
		 
	override void initialize(Object context) {
		if (!(context instanceof ProjectPlan)) {
			throw new IllegalArgumentException(
				String.format(illegalContext, context)
			)
		}
		projectPlan = context as ProjectPlan
		editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(projectPlan)
			?: WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain
		val Command deleteCommand = DeleteCommand.create(editingDomain,projectPlan.assignments);
 		editingDomain.getCommandStack().execute(deleteCommand);
 		projectPlan  = projectPlan as ProjectPlan
  	}
	
	override store(Object source, Object target) {
		storePair(source, target)
	}
	
	def dispatch ProjectPlan storePair(Object source, Object target) {
		throw new IllegalArgumentException(
			String.format(illegalPair, source, target)
		)
	}
	
	def dispatch ProjectPlan storePair(Project source, Employee target) {
		println("storePair: " + source.name + " -> " + target.name)
		println("editingDomain: " + AdapterFactoryEditingDomain.getEditingDomainFor(projectPlan))
		val Assignment assignment = ProjectPlanningFactory.eINSTANCE.createAssignment()
		assignment.employee = target
		assignment.project = source
	//	val Command deleteCommand = DeleteCommand.create(editingDomain,seminar.assignments);
	//	editingDomain.getCommandStack().execute(deleteCommand);
		
		val Command addCommand = AddCommand.create(editingDomain, projectPlan, projectPlan.assignments ,assignment);
	//	seminar.assignments.add(assignment)
		editingDomain.getCommandStack().execute(addCommand);
	//	val serializer = Guice.createInjector(new SeminarRuntimeModule()).getInstance(Serializer);
	// val String dsl = serializer.serialize(seminar);
		projectPlan.eResource.save(newHashMap())
		println("after save")
		projectPlan
	}
	
	
	override noRelationFound() {
		// return empty systemAllocation instance (for now we just do
		// this in order to pass the algorithMain/nonexistentAllocation
		// testcase)
		projectPlan
	}
	
}
{'fraction_non_alphanumeric': 0.08498362700764073, 'fraction_numerical': 0.0, 'mean_word_length': 5.751578947368421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2568437', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1781, 'n_words': 382}