Commit 9ffa0434 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

* workarounds and safety checks for openapi import

parent 625bff77
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ public class TDLHelper {
			modelFile = ws.getFile(new Path(resourceUri.toPlatformString(true)));
		} else if (resourceUri.isFile()) {
			// TODO
			modelFile = ws.getFile(new Path(resourceUri.toFileString()));
//			String uriString = resourceUri.toFileString();
//			java.net.URI uri = new java.net.URI(uriString);
//			IFile[] files = ws.findFilesForLocationURI(uri);
+2 −2
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class OpenAPI2TDLTranslatorNext extends AbstractTranslator {
		boolean generateJavaMappings = true;
		if (preferences != null)
			generateJavaMappings = preferences.getBoolean(PropertyPage.GENERATE_JAVA_MAPPING, false);
		if (generateJavaMappings) {
		if (generateJavaMappings && theTdlPackage!=null) {
			mappingsPackage = tdlFactory.eINSTANCE.createPackage();
			mappingsPackage.setName("JavaMapping");
			getGeneratedPackage().getNestedPackage().add(mappingsPackage);
@@ -270,7 +270,7 @@ public class OpenAPI2TDLTranslatorNext extends AbstractTranslator {
			}
		}

		if (generateJavaMappings)
		if (generateJavaMappings && mappingsPackage!=null)
			addMappings(filename, mappingsPackage, drmTarget, javaPackage);

		ensureUniqueNames(getGeneratedPackage());
+10 −2
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
@@ -71,7 +74,7 @@ public class ImportWizardPage extends WizardNewFileCreationPage {
		editor = new FileFieldEditor("fileSelect","Select Data File: ",fileSelectionArea); //NON-NLS-1 //NON-NLS-2
		editor.getTextControl(fileSelectionArea).addModifyListener(e -> {
			setSourcePath(new Path(ImportWizardPage.this.editor.getStringValue()));
			if (!getSourcePath().lastSegment().equals("null")) {
			if (getSourcePath().lastSegment()!=null && !getSourcePath().lastSegment().equals("null")) {
				preferences.put(lastUsed, getSourcePath().toOSString());
				setFileName(getSourcePath().lastSegment()+".tdltx"); //TODO: generalise
			}
@@ -127,8 +130,13 @@ public class ImportWizardPage extends WizardNewFileCreationPage {
			if (editor.getStringValue().endsWith(".yaml")) {
				//YAML
				System.out.println("From OpenAPI YAML...");
//				IWorkspace workspace = ResourcesPlugin.getWorkspace();
//				IWorkspaceRoot root = workspace.getRoot();
//				IPath location = root.getLocation();
				String content = ConverterNext.processToString(editor.getStringValue(), 
						editor.getStringValue()+".tdltx", 
//						editor.getStringValue()+".tdltx",
//						location.append(getContainerFullPath()).append(getFileName()).toOSString(),
						getContainerFullPath().append(getFileName()).toOSString(),
						"SOURCE_MAPPING", 
						"TARGET_MAPPING",
						inline