plugin/src/java/org/pm4knime/node/logmanipulation/merge/MergeUtil.java
public static XLog mergeLogsInternal(XLog log0, XLog log1, List<String> tKeys, List<String> eKeys,
			List<XAttribute> exTraceAttrList0, List<XAttribute> exEventAttrList0, List<XAttribute> traceAttrList1,
			List<XAttribute> eventAttrList1, ExecutionContext exec) throws CanceledExecutionException {
		XLog mlog = XLogUtil.clonePureLog(log0, "Merged Log");
		mlog.getAttributes().putAll(log1.getAttributes());
		// the attributes we remove is only for the traces with the same caseID. So it
		// means at end, we need to keep them all??
		// for other traces, we keep the old attributes there
		for (XAttribute attr : traceAttrList1) {
			String newKey = attr.getKey() + CFG_ATTRIBUTE_SUFFIX;
			mlog.getGlobalTraceAttributes().add(cloneAttribute(attr, newKey));
		}

		for (XAttribute attr : eventAttrList1) {
			String newKey = attr.getKey() + CFG_ATTRIBUTE_SUFFIX;
			mlog.getGlobalEventAttributes().add(cloneAttribute(attr, newKey));
		}

		// how to find and change the trace with the same id ramdomly??
		// create hash map, for the caseId and trace itself
		Map<String, XTrace> tMap = new HashMap();

		for (XTrace trace : log0) {
			exec.checkCanceled();
			XTrace nTrace = (XTrace) trace.clone();
			String attrValue = trace.getAttributes().get(tKeys.get(0)).toString();// delete the attributes here with the
																					// same names... But are we talking
																					// about
			tMap.put(attrValue, nTrace);
//				mlog.add(nTrace);
		}

		// put the first event log into the mlog
		for (XTrace trace : log1) {
			exec.checkCanceled();
			XTrace nTrace = (XTrace) trace.clone();
			String attrValue = trace.getAttributes().get(tKeys.get(1)).toString();// delete the attributes here with the
																					// same names... But are we talking
																					// about

			if (tMap.keySet().contains(attrValue)) {
				// combine them together for one event and one
				XTrace oTrace = tMap.get(attrValue);
				for (XEvent event : trace) {
					// just for the event with same eventID, we do this operation to make them as
					// one
					XEvent fe = findEvent(oTrace, event, eKeys.get(0), eKeys.get(1));
					if (fe != null) {
						// check this event attributes and other attributes from this one

						// fe delete the exclused list and add addition ones
						for (XAttribute exAttr : exEventAttrList0)
							fe.getAttributes().remove(exAttr.getKey());
						// add additional attr from log1
						for (XAttribute inAttr : eventAttrList1) {
							// here we should add values from the current event here
							String newKey = inAttr.getKey() + CFG_ATTRIBUTE_SUFFIX;
							// because it is a map, so if we use the same key, it's going to rewrite the
							// values
							// so the ways to do it, change the key for the new added attributes here.
							fe.getAttributes().put(newKey, cloneAttribute(inAttr, newKey));

						}
					} else {
						// for different ones, keep them as they are, for excluded part, also
						oTrace.insertOrdered((XEvent) event.clone());
					}

				}

				// deal with the attributes for trace
				for (XAttribute exAttr : exTraceAttrList0)
					oTrace.getAttributes().remove(exAttr.getKey());
				for (XAttribute inAttr : traceAttrList1) {
					String newKey = inAttr.getKey() + CFG_ATTRIBUTE_SUFFIX;
					// naming is important to show it out. fix the global attributes
					oTrace.getAttributes().put(newKey, cloneAttribute(inAttr, newKey));
				}

			} else {
				tMap.put(attrValue, nTrace);
			}

		}

		// convert map to mlog
		mlog.addAll(tMap.values());
		return mlog;
	}
// separate, we insert all events there
separate, we insert all events there
separate we insert all events there
public static XLog mergeLogsInternal(XLog log0, XLog log1, List<String> tKeys, List<String> eKeys,
			List<XAttribute> exTraceAttrList0, List<XAttribute> exEventAttrList0, List<XAttribute> traceAttrList1,
			List<XAttribute> eventAttrList1, ExecutionContext exec) throws CanceledExecutionException {
		XLog mlog = XLogUtil.clonePureLog(log0, "Merged Log");
		mlog.getAttributes().putAll(log1.getAttributes());
		for (XAttribute attr : traceAttrList1) {
			String newKey = attr.getKey() + CFG_ATTRIBUTE_SUFFIX;
			mlog.getGlobalTraceAttributes().add(cloneAttribute(attr, newKey));
		}
		for (XAttribute attr : eventAttrList1) {
			String newKey = attr.getKey() + CFG_ATTRIBUTE_SUFFIX;
			mlog.getGlobalEventAttributes().add(cloneAttribute(attr, newKey));
		}
		Map<String, XTrace> tMap = new HashMap();
		for (XTrace trace : log0) {
			exec.checkCanceled();
			XTrace nTrace = (XTrace) trace.clone();
			String attrValue = trace.getAttributes().get(tKeys.get(0)).toString();
			tMap.put(attrValue, nTrace);
		}
		for (XTrace trace : log1) {
			exec.checkCanceled();
			XTrace nTrace = (XTrace) trace.clone();
			String attrValue = trace.getAttributes().get(tKeys.get(1)).toString();
			if (tMap.keySet().contains(attrValue)) {
				XTrace oTrace = tMap.get(attrValue);
				for (XEvent event : trace) {
					XEvent fe = findEvent(oTrace, event, eKeys.get(0), eKeys.get(1));
					if (fe != null) {
						for (XAttribute exAttr : exEventAttrList0)
							fe.getAttributes().remove(exAttr.getKey());
						for (XAttribute inAttr : eventAttrList1) {
							String newKey = inAttr.getKey() + CFG_ATTRIBUTE_SUFFIX;
							fe.getAttributes().put(newKey, cloneAttribute(inAttr, newKey));
						}
					} else {
						oTrace.insertOrdered((XEvent) event.clone());
					}
				}
				for (XAttribute exAttr : exTraceAttrList0)
					oTrace.getAttributes().remove(exAttr.getKey());
				for (XAttribute inAttr : traceAttrList1) {
					String newKey = inAttr.getKey() + CFG_ATTRIBUTE_SUFFIX;
					oTrace.getAttributes().put(newKey, cloneAttribute(inAttr, newKey));
				}
			} else {
				tMap.put(attrValue, nTrace);
			}
		}
		mlog.addAll(tMap.values());
		return mlog;
	}
public static XLog mergeLogsInternal ( XLog log0 , XLog log1 , List < String > tKeys , List < String > eKeys , List < XAttribute > exTraceAttrList0 , List < XAttribute > exEventAttrList0 , List < XAttribute > traceAttrList1 , List < XAttribute > eventAttrList1 , ExecutionContext exec ) throws CanceledExecutionException { XLog mlog = XLogUtil . clonePureLog ( log0 , "Merged Log" ) ; mlog . getAttributes ( ) . putAll ( log1 . getAttributes ( ) ) ; for ( XAttribute attr : traceAttrList1 ) { String newKey = attr . getKey ( ) + CFG_ATTRIBUTE_SUFFIX ; mlog . getGlobalTraceAttributes ( ) . add ( cloneAttribute ( attr , newKey ) ) ; } for ( XAttribute attr : eventAttrList1 ) { String newKey = attr . getKey ( ) + CFG_ATTRIBUTE_SUFFIX ; mlog . getGlobalEventAttributes ( ) . add ( cloneAttribute ( attr , newKey ) ) ; } Map < String , XTrace > tMap = new HashMap ( ) ; for ( XTrace trace : log0 ) { exec . checkCanceled ( ) ; XTrace nTrace = ( XTrace ) trace . clone ( ) ; String attrValue = trace . getAttributes ( ) . get ( tKeys . get ( 0 ) ) . toString ( ) ; tMap . put ( attrValue , nTrace ) ; } for ( XTrace trace : log1 ) { exec . checkCanceled ( ) ; XTrace nTrace = ( XTrace ) trace . clone ( ) ; String attrValue = trace . getAttributes ( ) . get ( tKeys . get ( 1 ) ) . toString ( ) ; if ( tMap . keySet ( ) . contains ( attrValue ) ) { XTrace oTrace = tMap . get ( attrValue ) ; for ( XEvent event : trace ) { XEvent fe = findEvent ( oTrace , event , eKeys . get ( 0 ) , eKeys . get ( 1 ) ) ; if ( fe != null ) { for ( XAttribute exAttr : exEventAttrList0 ) fe . getAttributes ( ) . remove ( exAttr . getKey ( ) ) ; for ( XAttribute inAttr : eventAttrList1 ) { String newKey = inAttr . getKey ( ) + CFG_ATTRIBUTE_SUFFIX ; fe . getAttributes ( ) . put ( newKey , cloneAttribute ( inAttr , newKey ) ) ; } } else { oTrace . insertOrdered ( ( XEvent ) event . clone ( ) ) ; } } for ( XAttribute exAttr : exTraceAttrList0 ) oTrace . getAttributes ( ) . remove ( exAttr . getKey ( ) ) ; for ( XAttribute inAttr : traceAttrList1 ) { String newKey = inAttr . getKey ( ) + CFG_ATTRIBUTE_SUFFIX ; oTrace . getAttributes ( ) . put ( newKey , cloneAttribute ( inAttr , newKey ) ) ; } } else { tMap . put ( attrValue , nTrace ) ; } } mlog . addAll ( tMap . values ( ) ) ; return mlog ; }
separate, we insert all events there
separate we insert all events there
// the attributes we remove is only for the traces with the same caseID. So it // means at end, we need to keep them all?? // for other traces, we keep the old attributes there // how to find and change the trace with the same id ramdomly?? // create hash map, for the caseId and trace itself // delete the attributes here with the // same names... But are we talking // about //				mlog.add(nTrace); // put the first event log into the mlog // delete the attributes here with the // same names... But are we talking // about // combine them together for one event and one // just for the event with same eventID, we do this operation to make them as // one // check this event attributes and other attributes from this one // fe delete the exclused list and add addition ones // add additional attr from log1 // here we should add values from the current event here // because it is a map, so if we use the same key, it's going to rewrite the // values // so the ways to do it, change the key for the new added attributes here. // for different ones, keep them as they are, for excluded part, also // deal with the attributes for trace // naming is important to show it out. fix the global attributes // convert map to mlog