Eclipseplugins
pADatasetDefinitionFile.java
1 package com.proalpha.pds.templates.jet.trunk;
2 
3 import com.openedge.pdt.core.template.TemplateGenerationException;
4 import com.proalpha.pds.templates.jet.IpaTemplateGenerator;
5 import com.proalpha.pds.templates.data.GeneratorSettingsConstans;
6 
7 import java.util.Map;
8 import java.util.Date;
9 import java.text.SimpleDateFormat;
10 import com.proalpha.pds.templates.helper.CodeFormatter;
11 
13 {
14  protected static String nl;
15  public static synchronized pADatasetDefinitionFile create(String lineSeparator)
16  {
17  nl = lineSeparator;
19  nl = null;
20  return result;
21  }
22 
23  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
24  protected final String TEXT_1 = "&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r2" + NL + "&ANALYZE-RESUME" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR \"Update Information\" Procedure _INLINE" + NL + "/* Actions: ? ? ? ? adm/support/proc/ds_pa_01.w */" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure" + NL + "/******************************************************************************/" + NL + "/* @COPYRIGHT@ */" + NL + "/* Project: proALPHA */" + NL + "/* */";
25  protected final String TEXT_2 = NL;
26  protected final String TEXT_3 = NL + "/* */";
27  protected final String TEXT_4 = NL + "/* Current: @PAVERSION@ as of @PADATE@/@PALASTAUTHOR@ */" + NL + "/* */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* DESCRIPTION */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* */";
28  protected final String TEXT_5 = NL + "/* */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* PARAMETERS */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* Name Description */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* &ippModifier Dataset modifier (used in Classes and */" + NL + "/* Interfaces only). Valid values are private or */" + NL + "/* protected. */" + NL + "/* &ippStatic YES, if Dataset is defined STATIC (used in */" + NL + "/* Classes and Interfaces only). */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/* HISTORY */" + NL + "/*----------------------------------------------------------------------------*/" + NL + "/*@FILEHISTORY@*/" + NL + "/******************************************************************************/" + NL + "" + NL + "/* Procedure Information -----------------------------------------------------*/" + NL + "" + NL + "&SCOPED-DEFINE pa-XInclBasisName ";
29  protected final String TEXT_6 = NL + NL + "/* Globals -------------------------------------------------------------------*/" + NL + "" + NL + "/* SCOPEDs -------------------------------------------------------------------*/" + NL + "" + NL + "&SCOPED-DEFINE ppDatasetName ";
30  protected final String TEXT_7 = NL + "&SCOPED-DEFINE ppBusinessEntityObject ";
31  protected final String TEXT_8 = NL + "&SCOPED-DEFINE ppDataAccessObject ";
32  protected final String TEXT_9 = NL + "&SCOPED-DEFINE ppMasterDataValidation ";
33  protected final String TEXT_10 = NL + "&SCOPED-DEFINE ppReadOnly ";
34  protected final String TEXT_11 = NL + "&SCOPED-DEFINE ppGetChanges ";
35  protected final String TEXT_12 = NL + "&SCOPED-DEFINE ppExportProperties" + NL + "&SCOPED-DEFINE ppDatasetVersion 00001" + NL + "" + NL + "/* Variables -----------------------------------------------------------------*/" + NL + "/*----------------------------------------------------------------------------*/" + NL + "" + NL + "&IF DEFINED(ippOOABL) = 0" + NL + " or \"{&ippOOABL}\" = \"Definitions\" &THEN" + NL + "" + NL + " /* Temp-Tables -------------------------------------------------------------*/" + NL + "" + NL + " {.../.../incl/.._......tdf {&*}}" + NL + " {.../.../incl/.._......tdf {&*}}" + NL + " {.../.../incl/.._......tdf {&*}}" + NL + "" + NL + " /* ProDataSet Definition ---------------------------------------------------*/" + NL + "" + NL + " define " + NL + " {&ippModifier} " + NL + " &IF \"{&ippStatic}\" = \"yes\" &THEN " + NL + " static " + NL + " &ENDIF" + NL + " dataset {&ppDatasetName}" + NL + " &IF \"{&ippNoReferenceOnlySwitch}\" <> \"YES\" &THEN" + NL + " reference-only" + NL + " &ENDIF" + NL + " for ..." + NL + " " + NL + " data-relation dr... for <parent_buffer>,<child_buffer>" + NL + " relation-fields (<parent_field>,<child_field>) nested" + NL + " ." + NL + "" + NL + "&ENDIF" + NL + "" + NL + "&IF \"{&ippNoReferenceOnlySwitch}\" = \"YES\"" + NL + " AND ( DEFINED(ippOOABL) = 0" + NL + " OR \"{&ippOOABL}\" = \"Constructor\") &THEN" + NL + " {setproperty" + NL + " {&ppDatasetName}" + NL + " 'CascadeDeletiondr...':U" + NL + " 'yes/no':U}." + NL + "&ENDIF" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK" + NL + "" + NL + "/* ******************** Preprocessor Definitions ******************** */" + NL + "" + NL + "" + NL + "" + NL + "/* _UIB-PREPROCESSOR-BLOCK-END */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "" + NL + "/* *********************** Procedure Settings ************************ */" + NL + "" + NL + "&ANALYZE-SUSPEND _PROCEDURE-SETTINGS" + NL + "/* Settings for THIS-PROCEDURE" + NL + " Type: Include" + NL + " Allow:" + NL + " Frames: 0" + NL + " Add Fields to: Neither" + NL + " Other Settings: INCLUDE-ONLY" + NL + " */" + NL + "&ANALYZE-RESUME _END-PROCEDURE-SETTINGS" + NL + "" + NL + "/* ************************* Create Window ************************** */" + NL + "" + NL + "&ANALYZE-SUSPEND _CREATE-WINDOW" + NL + "/* DESIGN Window definition (used by the UIB)" + NL + " CREATE WINDOW Include ASSIGN" + NL + " HEIGHT = 8.1" + NL + " WIDTH = 55.2." + NL + "/* END WINDOW DEFINITION */" + NL + " */" + NL + "&ANALYZE-RESUME" + NL + "" + NL + "" + NL + "" + NL + "" + NL + "" + NL + "&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Include" + NL + "" + NL + "" + NL + "/* *************************** Main Block *************************** */" + NL + "" + NL + "{adm/template/incl/dt_pds00.i {&*}}" + NL + "" + NL + "/* _UIB-CODE-BLOCK-END */" + NL + "&ANALYZE-RESUME";
36 
37 /* (non-javadoc)
38  * @see ITemplateGenerator#generate(Object)
39  */
40 public String generate(Map<String, Object> wizardSettings) throws TemplateGenerationException
41  {
42  final StringBuffer stringBuffer = new StringBuffer();
43  String author = (String)wizardSettings.get(GeneratorSettingsConstans.AUTHOR);
44  String description = (String)wizardSettings.get(GeneratorSettingsConstans.DESCRIPTION);
45  String fileName = (String)wizardSettings.get(GeneratorSettingsConstans.FILE_NAME);
46  String product = (String)wizardSettings.get(GeneratorSettingsConstans.PRODUCT);
47  String productDesc = (String)wizardSettings.get(GeneratorSettingsConstans.PRODUCT_DESCRIPTION);
48  String module = (String)wizardSettings.get("Module");
49  String moduleDesc = (String)wizardSettings.get(GeneratorSettingsConstans.MODULE_DESCRIPTION);
50  String version = (String)wizardSettings.get(GeneratorSettingsConstans.VERSION);
51  String xbasename = fileName.replace(".","_");
52  Date date = new Date();
53  SimpleDateFormat year = new SimpleDateFormat("yyyy");
54  SimpleDateFormat today = new SimpleDateFormat("dd.MM.yyyy");
55  String datasetName = (String)wizardSettings.get(GeneratorSettingsConstans.DATASET_NAME);
56  String businessEntityObject = (String)wizardSettings.get(GeneratorSettingsConstans.BUSINESS_ENTITY_OBJECT);
57  String dataAccessObject = (String)wizardSettings.get(GeneratorSettingsConstans.DATA_ACCESS_OBJECT);
58  String masterDataValidation = ((String)wizardSettings.get(GeneratorSettingsConstans.MASTER_DATA_VALIDATION)).equals("true")?"yes":"no";
59  String readOnly = ((String)wizardSettings.get(GeneratorSettingsConstans.READ_ONLY)).equals("true")?"yes":"no";
60  String getChanges = ((String)wizardSettings.get(GeneratorSettingsConstans.GET_CHANGES)).equals("true")?"yes":"no";
61  stringBuffer.append(TEXT_1);
62  stringBuffer.append(TEXT_2);
63  stringBuffer.append(CodeFormatter.SingleLineComment("Name : " + fileName));
64  stringBuffer.append(TEXT_2);
65  stringBuffer.append(CodeFormatter.SingleLineComment("Product: " + product + " - " + productDesc ));
66  stringBuffer.append(TEXT_2);
67  stringBuffer.append(CodeFormatter.SingleLineComment("Module : " + module + " - " + moduleDesc ));
68  stringBuffer.append(TEXT_3);
69  stringBuffer.append(TEXT_2);
70  stringBuffer.append(CodeFormatter.SingleLineComment("Created: " + version + " as of " + today.format(date) + "/" + author));
71  stringBuffer.append(TEXT_4);
72  stringBuffer.append(TEXT_2);
73  stringBuffer.append(CodeFormatter.MultiLineComment(description));
74  stringBuffer.append(TEXT_5);
75  stringBuffer.append(xbasename);
76  stringBuffer.append(TEXT_6);
77  stringBuffer.append(datasetName);
78  stringBuffer.append(TEXT_7);
79  stringBuffer.append(businessEntityObject);
80  stringBuffer.append(TEXT_8);
81  stringBuffer.append(dataAccessObject);
82  stringBuffer.append(TEXT_9);
83  stringBuffer.append(masterDataValidation);
84  stringBuffer.append(TEXT_10);
85  stringBuffer.append(readOnly);
86  stringBuffer.append(TEXT_11);
87  stringBuffer.append(getChanges);
88  stringBuffer.append(TEXT_12);
89  stringBuffer.append(TEXT_2);
90  return stringBuffer.toString();
91  }
92 }