diff --git a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/ToolConstants.java b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/ToolConstants.java index ab0ec79..f0d6ff2 100644 --- a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/ToolConstants.java +++ b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/ToolConstants.java @@ -70,6 +70,7 @@ public class ToolConstants { public static final String MD_EXTENSION = ".md"; public static final String CONSTRAINTS_LIB_IMPORT = "ballerina/constraint"; public static final String ELEMENT = "Element"; + public static final String RESOURCE_PATH_SEPERATOR = "/"; public enum TokenPosition { BEGIN, diff --git a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/modelgen/ResourceContextGenerator.java b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/modelgen/ResourceContextGenerator.java index ef0ffd7..f13d544 100644 --- a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/modelgen/ResourceContextGenerator.java +++ b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/modelgen/ResourceContextGenerator.java @@ -101,7 +101,7 @@ private void populateResourceTemplateContexts(FHIRImplementationGuide ig) { resourceDefinitionAnnotation.setName(GeneratorUtils.getInstance().resolveSpecialCharacters(structureDefinition.getName())); DataTypesRegistry.getInstance().addDataType(GeneratorUtils.getInstance().resolveSpecialCharacters(structureDefinition.getName())); resourceDefinitionAnnotation.setBaseType(CommonUtil.getSplitTokenAt(structureDefinition - .getBaseDefinition(), File.separator, ToolConstants.TokenPosition.END)); + .getBaseDefinition(), ToolConstants.RESOURCE_PATH_SEPERATOR, ToolConstants.TokenPosition.END)); resourceDefinitionAnnotation.setProfile(this.resourceTemplateContextInstance.getProfile()); resourceDefinitionAnnotation.setElements(new HashMap<>()); this.resourceTemplateContextInstance.setResourceDefinitionAnnotation(resourceDefinitionAnnotation); diff --git a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/DatatypeTemplateGenerator.java b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/DatatypeTemplateGenerator.java index dbde69b..940d8f6 100644 --- a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/DatatypeTemplateGenerator.java +++ b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/DatatypeTemplateGenerator.java @@ -67,7 +67,7 @@ public void generate(ToolContext toolContext, Map generatorPrope if (!datatypeContexts.isEmpty()) { String filePath = CommonUtil.generateFilePath(packagePath, "", "datatypes.bal"); this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + - File.separator + "fhir_extended_datatypes.vm", templateContext, "", filePath); + ToolConstants.RESOURCE_PATH_SEPERATOR + "fhir_extended_datatypes.vm", templateContext, "", filePath); } } } diff --git a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/PackageTemplateGenerator.java b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/PackageTemplateGenerator.java index 6f6fdb5..f115a4e 100644 --- a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/PackageTemplateGenerator.java +++ b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/PackageTemplateGenerator.java @@ -135,22 +135,22 @@ private void generatePackageEssentials(BallerinaPackageGenToolConfig toolConfig) String packagePath = (String) this.packageProperties.get("packagePath"); String filePath = CommonUtil.generateFilePath(packagePath, "Ballerina" + ToolConstants.TOML_EXTENSION, ""); - this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "ballerina_toml.vm", + this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "ballerina_toml.vm", this.createTemplateContextForBallerinaToml(toolConfig), "", filePath); filePath = CommonUtil.generateFilePath(packagePath, "Package" + ToolConstants.MD_EXTENSION, ""); - this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "package.vm", + this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "package.vm", this.createTemplateContextForPackageMD(toolConfig), "", filePath); filePath = CommonUtil.generateFilePath(packagePath, "initializer" + ToolConstants.BAL_EXTENSION, ""); - this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "initializer.vm", + this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "initializer.vm", this.createTemplateContextForInitializer(), "", filePath); filePath = CommonUtil.generateFilePath(packagePath, "variables" + ToolConstants.BAL_EXTENSION, ""); - this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + File.separator + "variables.vm", + this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + ToolConstants.RESOURCE_PATH_SEPERATOR + "variables.vm", this.createTemplateContextForVariables(), "", filePath); } catch (CodeGenException e) { throw new CodeGenException("Error occurred while generating template artifacts for ballerina package ", e); diff --git a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/ResourceTemplateGenerator.java b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/ResourceTemplateGenerator.java index 240a6f9..9624002 100644 --- a/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/ResourceTemplateGenerator.java +++ b/native/fhir-to-bal-lib/src/main/java/org/wso2/healthcare/fhir/ballerina/packagegen/tool/templategen/ResourceTemplateGenerator.java @@ -99,7 +99,7 @@ private void generateFHIRResources() + ToolConstants.BAL_EXTENSION, ""); this.getTemplateEngine().generateOutputAsFile(ToolConstants.TEMPLATE_PATH + - File.separator + "fhir_resource.vm", this.createTemplateContextForResourceSkeletons( + ToolConstants.RESOURCE_PATH_SEPERATOR + "fhir_resource.vm", this.createTemplateContextForResourceSkeletons( resourceTemplateContext, this.packageTemplateContext), "", filePath); } } catch (CodeGenException e) { diff --git a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/BallerinaProjectConstants.java b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/BallerinaProjectConstants.java index 1dbcde2..d421aa9 100644 --- a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/BallerinaProjectConstants.java +++ b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/BallerinaProjectConstants.java @@ -29,6 +29,7 @@ public class BallerinaProjectConstants { public static final String BASE_PACKAGE_IMPORT_SUFFIX = "ballerinax/health.fhir."; public static final String SERVICE_PACKAGE_IMPORT_SUFFIX = "ballerinax/health.fhir"; public static final String INTERNATIONAL_PACKAGE_IMPORT_SUFFIX = "ballerinax/health.fhir.r4.international401"; + public static final String RESOURCE_PATH_SEPERATOR = "/"; public class PrintStrings { diff --git a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/MetaGenerator.java b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/MetaGenerator.java index ed19b63..ae0d2fb 100644 --- a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/MetaGenerator.java +++ b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/MetaGenerator.java @@ -41,13 +41,13 @@ public MetaGenerator(String targetDir) throws CodeGenException { public void generate(ToolContext toolContext, Map generatorProperties) throws CodeGenException { String directoryPath = generatorProperties.get("projectAPIPath") + File.separator; this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES + - File.separator + "packageMd.vm", createTemplateContextForMeta(generatorProperties), directoryPath, + BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "packageMd.vm", createTemplateContextForMeta(generatorProperties), directoryPath, "Package.md"); this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES + - File.separator + "gitignore.vm", createTemplateContextForMeta(generatorProperties), directoryPath, + BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "gitignore.vm", createTemplateContextForMeta(generatorProperties), directoryPath, ".gitignore"); this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES + - File.separator + "apiConfig.vm", createTemplateContextForMeta(generatorProperties), directoryPath, + BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "apiConfig.vm", createTemplateContextForMeta(generatorProperties), directoryPath, "api_config.bal"); } diff --git a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/ServiceGenerator.java b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/ServiceGenerator.java index fb3efb3..2e2b5ad 100644 --- a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/ServiceGenerator.java +++ b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/ServiceGenerator.java @@ -43,7 +43,7 @@ public ServiceGenerator(String targetDir) throws CodeGenException { public void generate(ToolContext toolContext, Map generatorProperties) throws CodeGenException { String directoryPath = generatorProperties.get("projectAPIPath") + File.separator; this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES + - File.separator + "balService.vm", createTemplateContextForBalService( + BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "balService.vm", createTemplateContextForBalService( generatorProperties), directoryPath, "service.bal"); } diff --git a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/TomlGenerator.java b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/TomlGenerator.java index 9f81ec9..271babe 100644 --- a/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/TomlGenerator.java +++ b/native/fhir-to-bal-template/src/main/java/org/wso2/healthcare/fhir/codegen/ballerina/project/tool/generator/TomlGenerator.java @@ -44,7 +44,7 @@ public TomlGenerator(String targetDir) throws CodeGenException { public void generate(ToolContext toolContext, Map generatorProperties) throws CodeGenException { String directoryPath = generatorProperties.get("projectAPIPath") + File.separator; this.getTemplateEngine().generateOutputAsFile(BallerinaProjectConstants.RESOURCE_PATH_TEMPLATES - + File.separator + "ballerinaToml.vm", + + BallerinaProjectConstants.RESOURCE_PATH_SEPERATOR + "ballerinaToml.vm", createTemplateContextForToml(generatorProperties), directoryPath, "Ballerina.toml"); }