<commit_before>/*******************************************************************************
 * Copyright (c) 2011 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.cda.core.internal.generate;

import java.io.PrintWriter;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.openhealthtools.mdht.uml.cda.core.profile.CDAPackage;
import org.openhealthtools.mdht.uml.cda.core.util.InstanceGenerator;
import org.openhealthtools.mdht.uml.cda.util.CDAUtil;
import org.openhealthtools.mdht.uml.common.util.UMLUtil;

public class Generate {

	public static void main(String[] args) {

		if (args.length != 4) {
			System.out.println("Error running XML Generate, Invalid arguments");
			return;
		}

		System.out.println("XML Sample Snippet generated for " + args[1]);
		System.out.println();
		System.out.println();
		System.out.println();

		ResourceSet resourceSet = new ResourceSetImpl();

		// Initialize registry
		Registry packageRegistry = resourceSet.getPackageRegistry();
		packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
		packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
		packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

		// CDA Profile to registry
		packageRegistry.put(CDAPackage.eNS_URI, CDAPackage.eINSTANCE);

		String umlPluginLocation = args[2];
		String cdaResourcePluginLocation = args[3];
		String cdaProfileLocation = org.openhealthtools.mdht.uml.cda.resources.util.CDAResource.CDA_PROFILE_URI +
				"#_cxOJEIEVEd6H8o-hO3-B4Q";

		String umlModelLocation = args[0];
		String umlClassName = args[1];

		// Initialize pathmaps
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
			UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
		Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();

		// Create and Add UML PathMaps
		URI uri = URI.createURI(umlPluginLocation);
		uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
		uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
		uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));

		// Create and Add CDA Profile PathMaps
		URI cdaresourceURI = URI.createURI(cdaResourcePluginLocation);
		URI cdaPathmap = URI.createURI(org.openhealthtools.mdht.uml.cda.resources.util.CDAResource.PROFILES_PATHMAP);
		uriMap.put(cdaPathmap, cdaresourceURI.appendSegment("profiles").appendSegment(""));
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(
			org.openhealthtools.mdht.uml.cda.core.profile.CDAPackage.eNS_URI, URI.createURI(cdaProfileLocation));

		// Load the CDA Packages
		CDAUtil.loadPackages();

		// Open the model
		URI modelFile = URI.createFileURI(umlModelLocation);

		Resource umlResource = resourceSet.getResource(modelFile, true);

		Package umlPackage = (Package) EcoreUtil.getObjectByType(
			umlResource.getContents(), UMLPackage.eINSTANCE.getPackage());

		if (umlPackage != null) {

			EcoreUtil.resolveAll(umlPackage);

			Class generationTarget = UMLUtil.getClassByName(umlPackage, umlClassName);

			if (generationTarget != null) {

				InstanceGenerator generator = new InstanceGenerator(true);

				EObject instance = generator.createInstance(generationTarget, Integer.MAX_VALUE);

				PrintWriter writer = new PrintWriter(System.out);

				generator.save(instance, writer);

				writer.close();

			}

		}

	}
<commit_msg>Changed levels to 50 for instance generation<commit_after>/*******************************************************************************
 * Copyright (c) 2011 <NAME>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.cda.core.internal.generate;

import java.io.PrintWriter;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLPackage;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.openhealthtools.mdht.uml.cda.core.profile.CDAPackage;
import org.openhealthtools.mdht.uml.cda.core.util.InstanceGenerator;
import org.openhealthtools.mdht.uml.cda.util.CDAUtil;
import org.openhealthtools.mdht.uml.common.util.UMLUtil;

public class Generate {

	public static void main(String[] args) {

		if (args.length != 4) {
			System.out.println("Error running XML Generate, Invalid arguments");
			return;
		}

		System.out.println("XML Sample Snippet generated for " + args[1]);
		System.out.println();
		System.out.println();
		System.out.println();

		ResourceSet resourceSet = new ResourceSetImpl();

		// Initialize registry
		Registry packageRegistry = resourceSet.getPackageRegistry();
		packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
		packageRegistry.put(Ecore2XMLPackage.eNS_URI, Ecore2XMLPackage.eINSTANCE);
		packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

		// CDA Profile to registry
		packageRegistry.put(CDAPackage.eNS_URI, CDAPackage.eINSTANCE);

		String umlPluginLocation = args[2];
		String cdaResourcePluginLocation = args[3];
		String cdaProfileLocation = org.openhealthtools.mdht.uml.cda.resources.util.CDAResource.CDA_PROFILE_URI +
				"#_cxOJEIEVEd6H8o-hO3-B4Q";

		String umlModelLocation = args[0];
		String umlClassName = args[1];

		// Initialize pathmaps
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
			UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
		Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();

		// Create and Add UML PathMaps
		URI uri = URI.createURI(umlPluginLocation);
		uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
		uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
		uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));

		// Create and Add CDA Profile PathMaps
		URI cdaresourceURI = URI.createURI(cdaResourcePluginLocation);
		URI cdaPathmap = URI.createURI(org.openhealthtools.mdht.uml.cda.resources.util.CDAResource.PROFILES_PATHMAP);
		uriMap.put(cdaPathmap, cdaresourceURI.appendSegment("profiles").appendSegment(""));
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(
			org.openhealthtools.mdht.uml.cda.core.profile.CDAPackage.eNS_URI, URI.createURI(cdaProfileLocation));

		// Load the CDA Packages
		CDAUtil.loadPackages();

		// Open the model
		URI modelFile = URI.createFileURI(umlModelLocation);

		Resource umlResource = resourceSet.getResource(modelFile, true);

		Package umlPackage = (Package) EcoreUtil.getObjectByType(
			umlResource.getContents(), UMLPackage.eINSTANCE.getPackage());

		if (umlPackage != null) {

			EcoreUtil.resolveAll(umlPackage);

			Class generationTarget = UMLUtil.getClassByName(umlPackage, umlClassName);

			if (generationTarget != null) {

				InstanceGenerator generator = new InstanceGenerator(true);

				EObject instance = generator.createInstance(generationTarget, 50);

				PrintWriter writer = new PrintWriter(System.out);

				generator.save(instance, writer);

				writer.close();

			}

		}

	}

{'fraction_non_alphanumeric': 0.14739756367663345, 'fraction_numerical': 0.006423034330011074, 'mean_word_length': 5.450714285714286, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '6446264', 'n_tokens_mistral': 3091, 'n_tokens_neox': 2886, 'n_words': 476}