	protected void checkSemantic(final String bpmnFileName,
			boolean checkActivities, boolean checkEvents,
			boolean checkMessageFlow, MainProcess mainProcess)
					throws IOException {
		final Diagram diagramFor = ModelHelper.getDiagramFor(mainProcess,null);
		DiagramEditPart dep;
		try{
			dep = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagramFor, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
		} catch(Exception ex){
			dep = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagramFor, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
		}
		MainProcessEditPart mped = (MainProcessEditPart) dep;
		IBonitaModelExporter exporter = new BonitaModelExporterImpl(mped) ;
		File bpmnFileExported = File.createTempFile("withAllExported", ".bpmn");
		final boolean transformed = new BonitaToBPMN().transform(exporter, bpmnFileExported, new NullProgressMonitor());
		assertTrue("Error during export", transformed);
		ResourceSet resourceSet1 = new ResourceSetImpl();
		final Map<String, Object> extensionToFactoryMap = resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap();
		final DiResourceFactoryImpl diResourceFactoryImpl = new DiResourceFactoryImpl();
		extensionToFactoryMap.put("bpmn", diResourceFactoryImpl);
		URL bpmnResource = FileLocator.toFileURL(BPMNImportExportTest.class.getResource(bpmnFileName));
		Resource resource1 = resourceSet1.createResource(URI.createFileURI(bpmnResource.getFile()));
		resource1.load(Collections.emptyMap());
		Resource resource2 = resourceSet1.createResource(URI.createFileURI(bpmnFileExported.getAbsolutePath()));
		resource2.load(Collections.emptyMap());
		DocumentRoot model1 = (DocumentRoot) resource1.getContents().get(0);
		DocumentRoot model2 = (DocumentRoot) resource2.getContents().get(0);
		int nbProcess1 = 0;
		Set<String> processNames = new HashSet<String>();
		List<String> activityNames = new ArrayList<String>();
		int nbActivity1 = 0;
		int nbBoundaryEvent1 = 0;
		int nbTsignal1 = 0;
		int nbEvents1 = 0;
		int nbTextannotation1 = 0;
		int nbMessageFlow1 = 0;
		int nbProcessItemeDefinition1 = 0;
		int nbDataObject1 = 0;
		int nbProperty1 = 0;
		for(TRootElement rootElement : model1.getDefinitions().getRootElement()){
			if(rootElement instanceof TProcess){
				nbProcess1++;
				final String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();
				processNames.add(processName);
				for(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){
					if(tArtifact instanceof TTextAnnotation){
						nbTextannotation1++;
					}
				}
				for(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){
					if(tFlowElement instanceof TActivity){                   	
						nbActivity1++;
						String name  = getFlowElementName((TActivity) tFlowElement);
						activityNames.add(name);
						if(tFlowElement instanceof TSubProcess){
							if(((TSubProcess) tFlowElement).isTriggeredByEvent()){
								nbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement) ;
								nbActivity1--;
							} else {
								nbProcess1++;
								nbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);
							}
						}
						System.out.println("activity count for model 1 "+ nbActivity1 + tFlowElement.getId() +" ### "+ tFlowElement.getName());
						nbProperty1 += ((TActivity) tFlowElement).getProperty().size();
					} else if(tFlowElement instanceof TDataObject){
						nbDataObject1++;
					} else if(tFlowElement instanceof TIntermediateThrowEvent){
						if((((TThrowEvent) tFlowElement).getEventDefinition() == null
								|| ((TThrowEvent) tFlowElement).getEventDefinition().isEmpty())
								&& (((TThrowEvent) tFlowElement).getEventDefinitionRef() == null
								|| ((TThrowEvent) tFlowElement).getEventDefinitionRef().isEmpty())){
							nbActivity1++;
						}
					}
				}
			} else if(rootElement instanceof TBoundaryEvent){
				nbBoundaryEvent1++;
			} else if(rootElement instanceof TSignal){
				nbTsignal1++;
			} else if(rootElement instanceof TEvent){
				nbEvents1++;
			} else if(rootElement instanceof TCollaboration){
				nbMessageFlow1+=((TCollaboration) rootElement).getMessageFlow().size();
			} else if(rootElement instanceof TItemDefinition){
				nbProcessItemeDefinition1++;
			}
		}
		int nbProcess2 = 0;
		int nbBoundaryEvent2 = 0;
		int nbActivity2 = 0;
		int nbTsignal2 = 0;
		int nbEvents2 = 0;
		int nbTextannotation2 = 0;
		int nbMessageFlow2 =0;
		int nbProcessItemeDefinition2 = 0;
		int nbDataObject2 = 0;
		int nbProperty2 = 0;
		for(TRootElement rootElement : model2.getDefinitions().getRootElement()){
			if(rootElement instanceof TProcess){
				nbProcess2++;
				final String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();
				if(!processNames.remove(processName)){
					System.out.println(processName+ "  has appeared");
				}
				for(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){
					if(tArtifact instanceof TTextAnnotation){
						nbTextannotation2++;
					}
				}
				for(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){
					if(tFlowElement instanceof TActivity){
						nbActivity2++;
						String name  = getFlowElementName((TActivity) tFlowElement);
						if(!activityNames.remove(name)){
							System.out.println("The activity : "+name +" is missing ");
						}
						if(tFlowElement instanceof TSubProcess){
							nbActivity2 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);
							if(((TSubProcess) tFlowElement).isTriggeredByEvent()){
								nbActivity2--;
							}
						}
						System.out.println("activity count for model 2 "+ nbActivity2 + tFlowElement.getId() +" ### "+ tFlowElement.getName());
						nbProperty2 += ((TActivity) tFlowElement).getProperty().size();
					} else if(tFlowElement instanceof TDataObject){
						nbDataObject2++;
					}
				}
			} else if(rootElement instanceof TBoundaryEvent){
				nbBoundaryEvent2++;
			} else if(rootElement instanceof TSignal){
				nbTsignal2++;
			} else if(rootElement instanceof TEvent){
				nbEvents2++;
			}  else if(rootElement instanceof TCollaboration){
				nbMessageFlow2 = ((TCollaboration) rootElement).getMessageFlow().size();
			} else if(rootElement instanceof TItemDefinition){
				nbProcessItemeDefinition2++;
			}
		}
		Collection<String> ids = new HashSet<String>();
		Collection<String> duplicatedIds = new HashSet<String>();
		Collection<EObject> noIds = new HashSet<EObject>();
		for (Iterator<EObject> iterator = model2.eAllContents(); iterator.hasNext();) {
			EObject object = iterator.next();
			if(object instanceof TBaseElement){
				String id = ((TBaseElement) object).getId();
				if(id == null){
					noIds.add(object);
				}
				if(ids.contains(id)){
					duplicatedIds.add(id);
				}
				ids.add(id);
			}
		}
		if(!activityNames.isEmpty()){
			System.out.println("Some activity have disappeared for diagram:" + bpmnFileName);
			for (String activityName : activityNames) {
				System.out.println(activityName+"\n");
			}
		}
		assertEquals("We don't find the same number of process", nbProcess1, nbProcess2);
		assertTrue("There are missing processes:"+processNames.toString(), processNames.isEmpty());
		assertEquals("We don't find the same number of boundaries event", nbBoundaryEvent1, nbBoundaryEvent2);
		if(checkActivities){
			assertEquals("We don't find the same number of activities", nbActivity1, nbActivity2);
		}
		assertEquals("We don't find the same number of TSignal defined", nbTsignal1, nbTsignal2);
		if(checkEvents){
			assertEquals("We don't find the same number of TEvent defined", nbEvents1, nbEvents2);
		}
		if(checkMessageFlow){
			assertEquals("We don't find the same number of TMessageFlow defined", nbMessageFlow1, nbMessageFlow2);
		}
		assertTrue("There are null ids: "+noIds, noIds.isEmpty());
		assertTrue("There are duplicated ids: "+duplicatedIds, duplicatedIds.isEmpty());
		assertEquals("Some data were lost", nbDataObject1, nbDataObject2);
		assertEquals("Some property (transient data) were lost", nbProperty1, nbProperty2);
	}

	protected void checkSemantic(final String bpmnFileName,
			boolean checkActivities, boolean checkEvents,
			boolean checkMessageFlow, MainProcess mainProcess)
					throws IOException {
		final Diagram diagramFor = ModelHelper.getDiagramFor(mainProcess,null);
		DiagramEditPart dep;
		try{
			dep = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagramFor, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
		} catch(Exception ex){
			dep = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagramFor, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
		}
		MainProcessEditPart mped = (MainProcessEditPart) dep;
		IBonitaModelExporter exporter = new BonitaModelExporterImpl(mped) ;
		File bpmnFileExported = File.createTempFile("withAllExported", ".bpmn");
		final boolean transformed = new BonitaToBPMN().transform(exporter, bpmnFileExported, new NullProgressMonitor());
		assertTrue("Error during export", transformed);
		ResourceSet resourceSet1 = new ResourceSetImpl();
		final Map<String, Object> extensionToFactoryMap = resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap();
		final DiResourceFactoryImpl diResourceFactoryImpl = new DiResourceFactoryImpl();
		extensionToFactoryMap.put("bpmn", diResourceFactoryImpl);
		URL bpmnResource = FileLocator.toFileURL(BPMNImportExportTest.class.getResource(bpmnFileName));
		Resource resource1 = resourceSet1.createResource(URI.createFileURI(new File(bpmnResource.getFile()).getAbsolutePath()));
		resource1.load(Collections.emptyMap());
		Resource resource2 = resourceSet1.createResource(URI.createFileURI(bpmnFileExported.getAbsolutePath()));
		resource2.load(Collections.emptyMap());
		DocumentRoot model1 = (DocumentRoot) resource1.getContents().get(0);
		DocumentRoot model2 = (DocumentRoot) resource2.getContents().get(0);
		int nbProcess1 = 0;
		Set<String> processNames = new HashSet<String>();
		List<String> activityNames = new ArrayList<String>();
		int nbActivity1 = 0;
		int nbBoundaryEvent1 = 0;
		int nbTsignal1 = 0;
		int nbEvents1 = 0;
		int nbTextannotation1 = 0;
		int nbMessageFlow1 = 0;
		int nbProcessItemeDefinition1 = 0;
		int nbDataObject1 = 0;
		int nbProperty1 = 0;
		for(TRootElement rootElement : model1.getDefinitions().getRootElement()){
			if(rootElement instanceof TProcess){
				nbProcess1++;
				final String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();
				processNames.add(processName);
				for(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){
					if(tArtifact instanceof TTextAnnotation){
						nbTextannotation1++;
					}
				}
				for(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){
					if(tFlowElement instanceof TActivity){                   	
						nbActivity1++;
						String name  = getFlowElementName((TActivity) tFlowElement);
						activityNames.add(name);
						if(tFlowElement instanceof TSubProcess){
							if(((TSubProcess) tFlowElement).isTriggeredByEvent()){
								nbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement) ;
								nbActivity1--;
							} else {
								nbProcess1++;
								nbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);
							}
						}
						System.out.println("activity count for model 1 "+ nbActivity1 + tFlowElement.getId() +" ### "+ tFlowElement.getName());
						nbProperty1 += ((TActivity) tFlowElement).getProperty().size();
					} else if(tFlowElement instanceof TDataObject){
						nbDataObject1++;
					} else if(tFlowElement instanceof TIntermediateThrowEvent){
						if((((TThrowEvent) tFlowElement).getEventDefinition() == null
								|| ((TThrowEvent) tFlowElement).getEventDefinition().isEmpty())
								&& (((TThrowEvent) tFlowElement).getEventDefinitionRef() == null
								|| ((TThrowEvent) tFlowElement).getEventDefinitionRef().isEmpty())){
							nbActivity1++;
						}
					}
				}
			} else if(rootElement instanceof TBoundaryEvent){
				nbBoundaryEvent1++;
			} else if(rootElement instanceof TSignal){
				nbTsignal1++;
			} else if(rootElement instanceof TEvent){
				nbEvents1++;
			} else if(rootElement instanceof TCollaboration){
				nbMessageFlow1+=((TCollaboration) rootElement).getMessageFlow().size();
			} else if(rootElement instanceof TItemDefinition){
				nbProcessItemeDefinition1++;
			}
		}
		int nbProcess2 = 0;
		int nbBoundaryEvent2 = 0;
		int nbActivity2 = 0;
		int nbTsignal2 = 0;
		int nbEvents2 = 0;
		int nbTextannotation2 = 0;
		int nbMessageFlow2 =0;
		int nbProcessItemeDefinition2 = 0;
		int nbDataObject2 = 0;
		int nbProperty2 = 0;
		for(TRootElement rootElement : model2.getDefinitions().getRootElement()){
			if(rootElement instanceof TProcess){
				nbProcess2++;
				final String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();
				if(!processNames.remove(processName)){
					System.out.println(processName+ "  has appeared");
				}
				for(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){
					if(tArtifact instanceof TTextAnnotation){
						nbTextannotation2++;
					}
				}
				for(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){
					if(tFlowElement instanceof TActivity){
						nbActivity2++;
						String name  = getFlowElementName((TActivity) tFlowElement);
						if(!activityNames.remove(name)){
							System.out.println("The activity : "+name +" is missing ");
						}
						if(tFlowElement instanceof TSubProcess){
							nbActivity2 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);
							if(((TSubProcess) tFlowElement).isTriggeredByEvent()){
								nbActivity2--;
							}
						}
						System.out.println("activity count for model 2 "+ nbActivity2 + tFlowElement.getId() +" ### "+ tFlowElement.getName());
						nbProperty2 += ((TActivity) tFlowElement).getProperty().size();
					} else if(tFlowElement instanceof TDataObject){
						nbDataObject2++;
					}
				}
			} else if(rootElement instanceof TBoundaryEvent){
				nbBoundaryEvent2++;
			} else if(rootElement instanceof TSignal){
				nbTsignal2++;
			} else if(rootElement instanceof TEvent){
				nbEvents2++;
			}  else if(rootElement instanceof TCollaboration){
				nbMessageFlow2 = ((TCollaboration) rootElement).getMessageFlow().size();
			} else if(rootElement instanceof TItemDefinition){
				nbProcessItemeDefinition2++;
			}
		}
		Collection<String> ids = new HashSet<String>();
		Collection<String> duplicatedIds = new HashSet<String>();
		Collection<EObject> noIds = new HashSet<EObject>();
		for (Iterator<EObject> iterator = model2.eAllContents(); iterator.hasNext();) {
			EObject object = iterator.next();
			if(object instanceof TBaseElement){
				String id = ((TBaseElement) object).getId();
				if(id == null){
					noIds.add(object);
				}
				if(ids.contains(id)){
					duplicatedIds.add(id);
				}
				ids.add(id);
			}
		}
		if(!activityNames.isEmpty()){
			System.out.println("Some activity have disappeared for diagram:" + bpmnFileName);
			for (String activityName : activityNames) {
				System.out.println(activityName+"\n");
			}
		}
		assertEquals("We don't find the same number of process", nbProcess1, nbProcess2);
		assertTrue("There are missing processes:"+processNames.toString(), processNames.isEmpty());
		assertEquals("We don't find the same number of boundaries event", nbBoundaryEvent1, nbBoundaryEvent2);
		if(checkActivities){
			assertEquals("We don't find the same number of activities", nbActivity1, nbActivity2);
		}
		assertEquals("We don't find the same number of TSignal defined", nbTsignal1, nbTsignal2);
		if(checkEvents){
			assertEquals("We don't find the same number of TEvent defined", nbEvents1, nbEvents2);
		}
		if(checkMessageFlow){
			assertEquals("We don't find the same number of TMessageFlow defined", nbMessageFlow1, nbMessageFlow2);
		}
		assertTrue("There are null ids: "+noIds, noIds.isEmpty());
		assertTrue("There are duplicated ids: "+duplicatedIds, duplicatedIds.isEmpty());
		assertEquals("Some data were lost", nbDataObject1, nbDataObject2);
		assertEquals("Some property (transient data) were lost", nbProperty1, nbProperty2);
	}
