First Tier

My primary skills. They are currently used in my daily work. I can get most jobs done without or with litter help.

Second Tier

I used to spend lots of time on these technologies. But not currently used or occasionally used. I can pick them up very quick and get most job done with Google search and online help.

Third Tier

ASP, .Net, ksh, WordPress (this resume website is built on WordPress)

code examples

Java/JSP/J2EE: > 8yrs

Java Code Example - Abstract Class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.xxxxxxx.reports;
 
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
 
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
import com.bluemartini.dna.DNAList;
import com.bluemartini.dna.DNAListArray;
 
public abstract class AbstractReportWorkbook {
   protected String            _path            = null;
   protected String            _fileName        = null;
   protected HSSFWorkbook      _wb              = null;
   protected HSSFCellStyle     _headerStyle     = null;
   protected DNAListArray      _columns         = null;
   protected int               _sheetIndex      = 0;
   protected HSSFSheet         _sheet           = null;
 
   final public static String   CELL_TYPE_TEXT      = "text";
   final public static String   CELL_TYPE_CURRENCY  = "currency";
 
   // to get column code ("A", "B", "C" ...) by index, up to 26 columns for now
   final static private String   COLUMNCODES    = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
   public char getColumnCodeByIndex(short index) {
      if (index < 26)
         return COLUMNCODES.charAt(index);
      else
         return ' ';
   }
 
   public AbstractReportWorkbook(String path, DNAList rptConfig, String extension) {
      _fileName = rptConfig.getString("reportName", "nonamespecified") + "_" + extension + ".xls";
 
      _path = path;
 
      _wb = new HSSFWorkbook();
 
      _columns = rptConfig.getListArray("columns");
 
      // createAllStyles();
      // createSheet(++_sheetIndex);
   }
 
   public void flush() {
      if (_wb == null || _path == null || _fileName == null)
         return;
 
      try {
         FileOutputStream _fileOut = new FileOutputStream(_path + "/" + _fileName);
         _wb.write(_fileOut);
         _fileOut.close();
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
 
   public String getFileName() {
      return _fileName;
   }
 
   public String getFullPath() {
      return _path + "/" + _fileName;
   }
}

Java Code Example - Taglib

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.twinhill.microsites.taglibs.tag;
 
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
 
import com.bluemartini.artisa.core.ArtisaLogName;
import com.bluemartini.b2b.B2BOrderArray;
import com.bluemartini.b2b.util.B2BOrderUtil;
import com.bluemartini.dna.BMException;
import com.bluemartini.dna.BMLog;
import com.bluemartini.dna.BusinessObject;
import com.bluemartini.html.HTMLContext;
 
public class OrderHistoryTag extends SimpleTagSupport {
	/** Name of the scoped variable exposing the Page. */
	private String varName;
 
	/** Expression representing the user account object */
	private Object user_;
 
	/** Scope of the scoped variable exposing the Page. */
	private int scope = PageContext.PAGE_SCOPE;
 
	/** Log component */
	private static final int LOG = BMLog.getComponentID(ArtisaLogName.TAGLIB);
 
	public OrderHistoryTag() {
		super();
	}
 
	/**
	 * <p>
	 * Sets the user from whom the orders placed will be retrieved. This is not
	 * required. If missed, the current user in htmlcontext will be used.
	 * </p>
	 *
	 * @param user
	 *            the user
	 */
	public void setUser(Object user) {
		user_ = user;
	}
 
	/**
	 * <p>
	 * Specifies the name of the scoped variable exposing the Page.
	 * </p>
	 *
	 * @param name
	 *            name of the scoped variable exposing the assortment
	 */
	public void setVar(String name) {
		this.varName = name;
	}
 
	/**
	 * <p>
	 * Specifies the scope of the scoped variable exposing the Page.
	 * </p>
	 *
	 * @param scope
	 *            scope of the variable exposing the Page, which must be
	 *            <code>"page"</code>, <code>"request"</code>,
	 *            <code>"session"</code>, or <code>"application"</code>
	 *            (defaults to <code>"page"</code> if unspecified or an improper
	 *            value is specified)
	 */
	public void setScope(String scope) {
		if ("request".equalsIgnoreCase(scope)) {
			this.scope = PageContext.REQUEST_SCOPE;
		} else if ("session".equalsIgnoreCase(scope)) {
			this.scope = PageContext.SESSION_SCOPE;
		} else if ("application".equalsIgnoreCase(scope)) {
			this.scope = PageContext.APPLICATION_SCOPE;
		} else {
			this.scope = PageContext.PAGE_SCOPE;
		}
	}
 
	/**
	 * <p>
	 * Display all orders placed for the <code>user</code>. Exposes the
	 * order list as an array via the scoped variable specified by the
	 * <code>var</code> attribute.
	 * </p>
	 *
	 * @throws JspException
	 *             if the template attribute is empty
	 */
	public void doTag() throws JspException {
 
		Long userID = null;
 
		if (user_ != null && user_ instanceof BusinessObject && ((BusinessObject) user_).contains("usa_id")) {
			userID = ((BusinessObject) user_).getLong("usa_id");
		} else {
			BusinessObject bo = HTMLContext.getContext().getFormData()
					.getBusinessObject("CURRENT_USER");
			if (bo != null)
				userID = bo.getLong("usa_id");
		}
 
		if (userID != null) {
			// the order array that will be returned to JSP.
			B2BOrderArray orderHistory = null;
 
			try {
				orderHistory = new B2BOrderArray(B2BOrderUtil.getOrderHistoryForUser(userID));
			} catch (BMException e) {
				e.printStackTrace();
				orderHistory = null;
			}
 
			// add to jsp context
			getJspContext().setAttribute(this.varName, orderHistory, this.scope);
		} else {
			BMLog.log(LOG, 0, "Unable to identify current user!");
			// add empty DNAListArray to JSP
			getJspContext().setAttribute(this.varName, null, this.scope);
		}
 
		// Set default values in preparation for next use
		this.varName = null;
		this.user_ = null;
		this.scope = PageContext.PAGE_SCOPE;
	}
}

Java Code Example - Maven plugin

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
package com.twinhill.mavenplugin;
 
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
 
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
 
/**
 * Goal to set environment variables.
 *
 * @goal setenv
 * @phase prepare-package
 */
public class MakeEnvFiles extends AbstractMojo {
	private static final int				NUM_WARNINGS	= 10;
	private static final String				dateFormat		= "mm/dd/yyyy";
	private static final SimpleDateFormat	sdf				= new SimpleDateFormat(dateFormat);
 
	private PrintWriter						pw;
	//private String							fileName;
 
	/**
	 * Location of the file.
	 *
	 * @parameter expression="${project.build.directory}"
	 * @required
	 */
	private String							outputDirectory;
 
	/**
	 * the path to the spreadsheet.
	 *
	 * @parameter expression="${bms.build.spreadsheet}"
	 * @required
	 */
	private String							spreadsheet;
 
	/**
	 * The name of the application. For example: chase, gensite, ups....
	 *
	 * @parameter
	 * @required
	 */
	private String[]						appNames;
 
	/**
	 * The name of the target. For example: local, backoffice, dev, stage, production.
	 *
	 * @parameter
	 * @required
	 */
	private String							targetName;
 
	/**
	 * Is the ear/war running in j2ee mode?.
	 *
	 * @parameter default-value=true
	 */
	private boolean							j2eeMode;
 
	/**
	 * The path to the web.xml in source, not target.
	 *
	 * @parameter default-value="${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml"
	 */
	private String							webxmlpath;
 
	public void execute() throws MojoExecutionException {
 
		getLog().info("j2eeMode = " + j2eeMode);
		getLog().info("webxmlpath = " + webxmlpath);
 
		// create output file
		if (!outputDirectory.endsWith("/") && !outputDirectory.endsWith("\"))
			outputDirectory = outputDirectory + "/";
 
		File outDir = new File(outputDirectory);
		if (!outDir.isDirectory())
			throw new MojoExecutionException(outputDirectory + " is not a valid directory!");
 
		String fileName = outputDirectory + "system.env";
		try {
			File f = new File(fileName);
			if (f.exists()) {
				f.delete();
			}
 
			if (f.createNewFile()) {
				pw = new PrintWriter(new BufferedWriter(new FileWriter(f)));
				pw.println("# Generated from " + spreadsheet + " for target: " + targetName + " - " + new Date());
			}
		} catch (IOException e) {
			throw new MojoExecutionException("Unable to create file: " + fileName, e);
		}
 
		// read spreadsheet
		InputStream inp = null;
		try {
			inp = new FileInputStream(spreadsheet);
		} catch (FileNotFoundException fnfe) {
			throw new MojoExecutionException("File " + spreadsheet + " not found", fnfe);
		}
		Workbook wb = null;
		try {
			wb = WorkbookFactory.create(inp);
		} catch (InvalidFormatException ife) {
			throw new MojoExecutionException("Invalid file format for " + spreadsheet, ife);
			// e1.printStackTrace();
		} catch (IOException e1) {
			throw new MojoExecutionException("Error creating workbook", e1);
		}
 
		HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator((HSSFWorkbook) wb);
 
		int numSheets = wb.getNumberOfSheets();
		for (int i = 0; i < numSheets; i++) {
			Sheet sheet = wb.getSheetAt(i);
			String sheetName = sheet.getSheetName();
			for (String appName : appNames) {
				if (appName.equalsIgnoreCase(sheetName)) {
					pw.println("################## variables from " + sheetName + " ##################");
					processSheet(sheet, eval);
					break;
				}
			}
		}
 
		if (pw != null)
			pw.close();
	}
 
	protected void processSheet(Sheet sheet, HSSFFormulaEvaluator eval) throws MojoExecutionException {
		boolean firstRow = true;
		int numErrors = 0;
		int colIndex = -1;
		for (Row row : sheet) {
			if (firstRow) {
				colIndex = getColIndex(row);
				if (colIndex < 0)
					throw new MojoExecutionException("Can not find the target:" + targetName);
 
				firstRow = false;
			} else {
				String varName = null;
				Cell cell = row.getCell(0);
				try {
					varName = cell.getStringCellValue();
					if (varName == null || varName.length() == 0)
						continue;
				} catch (Exception e) {
					continue;
				}
 
				cell = row.getCell(colIndex);
 
				if (cell == null) {
					if (numErrors++ < NUM_WARNINGS) {
						//project.log("No value for " + varName + " in environment " + envName, Project.MSG_WARN);
					} else if (numErrors == NUM_WARNINGS + 1) {
						//project.log("More missing values found....");
					}
					continue;
				}
 
				pw.print(varName);
				pw.print("=");
				String val = null;
 
				val = getCellValue(eval, cell);
				pw.println(val);
			}
		}
	}
 
	private int getColIndex(Row row) {
		int colIndex = -1;
		for (Cell cell : row) {
			if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
				String title = cell.getStringCellValue();
				if (targetName.equalsIgnoreCase(title)) {
					colIndex = cell.getColumnIndex();
					break;
				}
			}
		}
		return colIndex;
	}
 
	protected String getCellValue(HSSFFormulaEvaluator eval, Cell cell) {
		String val = null;
		switch (cell.getCellType()) {
			case Cell.CELL_TYPE_STRING:
				val = cell.getStringCellValue();
				break;
			case Cell.CELL_TYPE_NUMERIC:
				if (DateUtil.isCellDateFormatted(cell)) {
					Date dt = cell.getDateCellValue();
					val = sdf.format(dt);
				} else {
					double dValue = cell.getNumericCellValue();
					long lValue = (long) dValue;
					if (lValue < dValue) {
						val = Double.toString(dValue);
					} else {
						val = Long.toString(lValue);
					}
				}
				break;
			case Cell.CELL_TYPE_BOOLEAN:
				val = Boolean.toString(cell.getBooleanCellValue());
				break;
			case Cell.CELL_TYPE_FORMULA:
				CellValue cellVal = eval.evaluate(cell);
				val = getCellValue(eval, cellVal);
				break;
		}
		return val;
	}
 
	protected String getCellValue(HSSFFormulaEvaluator eval, CellValue cell) {
		String val = null;
		switch (cell.getCellType()) {
			case Cell.CELL_TYPE_STRING:
				val = cell.getStringValue();
				break;
			case Cell.CELL_TYPE_NUMERIC:
 
				double dValue = cell.getNumberValue();
				long lValue = (long) dValue;
				if (Math.abs(lValue) < Math.abs(dValue)) {
					val = Double.toString(dValue);
				} else {
					val = Long.toString(lValue);
				}
				break;
			case Cell.CELL_TYPE_BOOLEAN:
				val = Boolean.toString(cell.getBooleanValue());
				break;
		}
		return val;
	}
 
	/*
	 * private ArrayList<env> getEnvList(Row row, ArrayList<env> envs) throws MojoExecutionException {
	 * boolean firstCell = true;
	 * for (Cell cell : row) {
	 * if (firstCell) {
	 * firstCell = false;
	 * continue;
	 * }
	 * if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
	 * String envName = cell.getStringCellValue();
	 * cell.getColumnIndex();
	 * //if (!"notes".equalsIgnoreCase(envName)) {
	 * if (targetName.equalsIgnoreCase(envName)) {
	 * StringBuilder envBuff = new StringBuilder(128);
	 * envBuff.append(outputDirectory);
	 * envBuff.append("/");
	 * envBuff.append(envName);
	 * envBuff.append(".env");
	 * String envFileName = envBuff.toString();
	 * PrintWriter pw;
	 * try {
	 * File f = new File(envFileName);
	 * File parent = f.getParentFile();
	 * if (!parent.exists()) {
	 * parent.mkdirs();
	 * }
	 * pw = new PrintWriter(new BufferedWriter(new FileWriter(f)));
	 * } catch (IOException e) {
	 * throw new MojoExecutionException("Creating " + envFileName + " failed", e);
	 * }
	 * pw.println("# " + envFileName + " - generated from " + spreadsheet);
	 * //project.log("Generating " + envFileName);
	 * Env env = new Env();
	 * env.envName = envName;
	 * env.pw = pw;
	 * env.fileName = envFileName;
	 * env.index = cell.getColumnIndex();
	 * envs.add(env);
	 * }
	 * } else {
	 * throw new MojoExecutionException("Cell " + (cell.getColumnIndex() + 1)
	 * + " in the first row isn't a string!");
	 * }
	 * }
	 * return envs;
	 * }
	 */
 
	/*
	 * protected static class Env {
	 * PrintWriter pw;
	 * String envName;
	 * String fileName;
	 * int index;
	 * }
	 */
}

Java Code Example - StringBuilder

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.twinhill.isd.trigger;
 
import com.bluemartini.dna.DNAList;
import com.bluemartini.dna.DNAListIterator;
import com.twinhill.isd.ISDStartup;
 
public class TriggerFileRecord {
	private String	_type	= null;
	private DNAList	_fields	= null;
	private StringBuilder _sb = new StringBuilder(512);
 
	public TriggerFileRecord(String type) {
		_type = type;
		_fields = ISDStartup.getTriggerFileFieldsDNA().getList(_type).copy();
 
		DNAListIterator iter = _fields.iterator();
		while (iter.hasNext()) {
			iter.next();
			DNAList aField = iter.getList();
			TriggerFileField triggerField = new TriggerFileField(aField);
			updateStringBuilder(triggerField);
		}
	}
 
	public String getType() {
		return _type;
	}
 
	public void setValue(String fieldName, String fieldValue) {
		if (_fields.contains(fieldName)) {
			DNAList aField = _fields.getList(fieldName);
			TriggerFileField triggerField = new TriggerFileField(aField, fieldValue);
			updateStringBuilder(triggerField);
		}
	}
 
	private void updateStringBuilder(TriggerFileField triggerField) {
		//System.out.println("before.....|" + _sb.toString() + "|");
		int endPos = triggerField.getEndPos();
		int startPos = triggerField.getStartPos();
		int sbLength = _sb.length();
		String value = triggerField.getFormattedValue();
		//System.out.println(" the value is " +value  + " the startpos is " + startPos + " the endPos is " + endPos);
		if (sbLength <= startPos) {
			for (int i = 0; i < startPos - sbLength; i++)
				_sb.append(' ');
 
			_sb.append(triggerField.getFormattedValue());
		} else {
			_sb.replace(startPos, endPos + 1, value);
		}
		//System.out.println("after......|" + _sb.toString() + "|n");
	}
 
	public String getRecordAsString() {
		return _sb.toString();
	}
}

Java/JSP/J2EE

PL/SQL: > 6yrs

PLSQL Code Example - Package Header

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
CREATE OR REPLACE
PACKAGE TWINHILLUTIL
AS
  PROCEDURE setVersionNum(verNum IN INTEGER);
 
  PROCEDURE prodAvailForBSE(bseName IN VCHAR2);
 
  FUNCTION getPriceListID(plfID IN NUMBER) RETURN NUMBER;
 
  PROCEDURE getAtrIDDomIDFor(
      atrNM IN VCHAR2,
      atrID OUT NUMBER,
      domID OUT NUMBER);
 
  PROCEDURE prodAvail4PrimaryOrg(orgID IN NUMBER, contractPath IN VCHAR2);
 
  PROCEDURE prodAvail4Org(orgID IN NUMBER);
 
  FUNCTION getSKUFilterID(asstID IN VCHAR2) RETURN NUMBER;
 
  PROCEDURE displayAsstProd(asstID IN NUMBER);
 
  FUNCTION getProductPrice(objID IN NUMBER) RETURN b2b_main.object_price.obp_amt%TYPE;
 
  PROCEDURE printProductDetails( prdID IN NUMBER);
 
  FUNCTION isPrdFiltered(prdID IN NUMBER,skuFilterID IN NUMBER) RETURN NUMBER;
 
  PROCEDURE pritnProductDetailsInSKUFilter(prdID IN NUMBER, skuFilterID IN NUMBER);
 
  PROCEDURE formatoutput;
 
END TWINHILLUTIL;

PLSQL Code Example - Package Body

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
CREATE OR REPLACE
PACKAGE BODY TWINHILLUTIL
AS
  -- the version number, for different environments, it has different value
  versionnum  NUMBER := 2;
  colorAtrID  NUMBER;
  colorDomID  NUMBER;
  sizeAtrID   NUMBER;
  sizeDomID   NUMBER;
  pricelistID NUMBER;
  -- the result record type
  TYPE RESULT_TYPE IS RECORD
    (
      bse B2B_STORE.BUSINESS_ENTITY.BSE_LOGIN_NM%TYPE,
      org B2B_STORE.V_ORGANIZATION.ORG_LABEL%TYPE,
      subasst B2B_MAIN.V_ASSORTMENT.ast_label%TYPE,
      product B2B_MAIN.PRODUCT.PRD_CODE%TYPE,
      prdprice B2B_MAIN.OBJECT_PRICE.OBP_AMT%TYPE,
      filtered VCHAR2(20),
      color B2B_MAIN.DOMAIN_VALUE.DMV_STR_VAL%TYPE,
      thsize B2B_MAIN.DOMAIN_VALUE.DMV_STR_VAL%TYPE,
      upc B2B_MAIN.SKU.SKU_UPC%TYPE,
      PRICEOVERWRITE B2B_MAIN.OBJECT_PRICE.OBP_AMT%TYPE );
  TYPE RESULT_TAB IS TABLE OF RESULT_TYPE;
  -- declare a table to hold output result
  RESULTOUTPUT RESULT_TAB := RESULT_TAB();
  -- result table index
  ROWINDEX NUMBER         := 1;
 
  -- set version number since each database has its own version number
  PROCEDURE setVersionNum( verNum IN INTEGER) AS
  BEGIN
    versionnum := verNum;
  END SETVERSIONNUM;
 
  -- the main procedure to call
  PROCEDURE prodAvailForBSE( bseName IN VCHAR2) AS
    TYPE idstrpair IS RECORD (bseID NUMBER, contractPath VCHAR2(1024));
    bseINFO idstrpair;
    orgINFO idstrpair;
    rows NUMBER;
  BEGIN
    -- find the atr id and dom id for color attribute;
    GETATRIDDOMIDFOR('Color', COLORATRID, COLORDOMID);
 
    -- find the atr id and dom id for size attribute;
    GETATRIDDOMIDFOR('Size', SIZEATRID, SIZEDOMID);
 
    --dbms_output.put_line('debug 1');
    RESULTOUTPUT.EXTEND;
    RESULTOUTPUT(ROWINDEX).BSE := BSENAME;
 
    SELECT BSE_id,
            oba.oba_str_val
          INTO bseINFO
          FROM B2B_STORE.v_business_entity,
            B2B_STORE.object_attribute oba,
            B2B_MAIN.attribute atr
          WHERE LOWER(bse_login_nm) = LOWER(bseName)
          AND bse_status_cd         = 'A'
          AND bse_type_cd           = 'BYR'
          AND bse_id                = oba.oba_obj_id
          AND oba.oba_atr_id        = atr.atr_id
          AND atr.atr_nm            = 'Account_Assortment_Folder';
 
    FOR orgINFO IN
    (SELECT org_id,
          org_label
        FROM B2B_STORE.v_organization
        WHERE org_bse_id  = bseINFO.bseID
        AND org_status_cd = 'A'
    )
    LOOP
      resultoutput(rowindex).org := orgINFO.org_label;
      IF INSTR(ORGINFO.ORG_LABEL, 'Primary Organization') > 0 THEN
        -- if this org is a primary org
        prodAvail4PrimaryOrg(orgINFO.org_id, bseINFO.contractPath);
      ELSE
        -- if this org is NOT a primary org
        prodAvail4Org(orgINFO.org_id);
      END IF;
    END LOOP;
 
    FORMATOUTPUT;
 
  EXCEPTION
  WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.put_line('Can not find client: ' || bseName || ' or it does not have attribute Account_Assortment_Folder set');
  END prodAvailForBSE;
 
  -- handle the primary org
  -- go to contract assortment product folder first
  -- if the folder is empty, go the default contract
  PROCEDURE prodAvail4PrimaryOrg(orgID IN NUMBER, contractPath IN VCHAR2) AS
    fullContractPath VCHAR2(1024);
    rows             NUMBER;
    contractProdID   NUMBER;
    subasst B2B_MAIN.V_SUB_ASSORTMENT%ROWTYPE;
  BEGIN
    -- set price list id
    SELECT prl.prl_id
        INTO pricelistID
        FROM B2B_STORE.v_organization org,
          B2B_STORE.contract ctr,
          B2B_MAIN.v_price_list prl
        WHERE org.org_id      = orgID
        AND ctr.ctr_id        = org.org_default_ctr_id
        AND prl.prl_parent_id = ctr.ctr_plf_id
        AND prl.version       = versionnum
        AND PRL.PRL_STATUS_CD = 'A';
 
    FULLCONTRACTPATH     := '/Assortments' || CONTRACTPATH || '/ContractAssortment/Products';
 
    SELECT COUNT(*)
        INTO rows
        FROM B2B_MAIN.V_ASSORTMENT
        WHERE ast_path    = fullContractPath
        AND version       = versionnum
        AND AST_STATUS_CD = 'A';
 
    IF rows = 0 THEN
      DBMS_OUTPUT.put_line('Can not found assortment for: ' || fullContractPath);
    ELSE
      SELECT ast_id
          INTO contractProdID
          FROM B2B_MAIN.V_ASSORTMENT
          WHERE ast_path    = fullContractPath
          AND version       = versionnum
          AND AST_STATUS_CD = 'A';
 
      SELECT COUNT(*)
          INTO rows
          FROM B2B_MAIN.v_sub_assortment
          WHERE version     = versionnum
          AND sba_status_cd = 'A'
          AND SBA_PARENT_ID = CONTRACTPRODID;
 
      IF rows = 0 THEN
        -- the "Products" assortment does not have sub assortment
        -- go to regular orgnization
        prodAvail4Org(orgID);
      ELSE
        FOR subasst IN
        (SELECT      *
            FROM B2B_MAIN.v_sub_assortment
            WHERE version     = versionnum
            AND sba_status_cd = 'A'
            AND sba_parent_id = contractProdID
        )
        LOOP
          -- the "Products" assortment has sub assortment
          displayAsstProd(subasst.sba_id);
        END LOOP;
      END IF;
    END IF;
  END prodAvail4PrimaryOrg;
 
  -- handle regular (non-primary) org
  PROCEDURE prodAvail4Org(orgID IN NUMBER) AS
    CURSOR orgcursor IS
      SELECT org.org_id,
        org.org_label,
        ctr.ctr_ast_id,
        ctr.ctr_plf_id,
        ctr.ctr_begin_dt,
        ctr.ctr_end_dt
      FROM B2B_store.v_organization org,
        B2b_STORE.v_contract ctr
      WHERE org.org_id           = orgID
      AND org.org_status_cd      = 'A'
      AND org.org_default_ctr_id = ctr.ctr_id
      AND ctr.ctr_status_cd      = 'A'
      ORDER BY org.org_id;
    orgINFO orgcursor%ROWTYPE;
  BEGIN
    FOR orgINFO IN orgcursor
    LOOP
      IF orgINFO.ctr_ast_id IS NOT NULL THEN
        pricelistID := getPriceListID(orgINFO.ctr_plf_id);
        displayAsstProd(orgINFO.ctr_ast_id);
      ELSE
        DBMS_OUTPUT.put_line(orgINFO.org_label || ' does not have assortments.');
      END IF;
    END LOOP;
  END PRODAVAIL4ORG;
 
  FUNCTION getPriceListID(plfID IN NUMBER) RETURN NUMBER AS
    prlId NUMBER;
  BEGIN
    SELECT prl_id
        INTO prlId
        FROM B2B_MAIN.v_price_list
        WHERE prl_parent_id = plfID
        AND version         = versionnum
        AND prl_status_cd   = 'A';
    RETURN PRLID;
 
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RETURN 0;
  END getPriceListID;
 
 
  PROCEDURE displayAsstProd(asstID IN NUMBER) AS
    asstname VCHAR2(128);
    rows     NUMBER;
    subasstrel B2B_MAIN.relationship%ROWTYPE;
    subasst B2B_MAIN.V_ASSORTMENT%ROWTYPE;
    prodrel B2B_MAIN.relationship%ROWTYPE;
    skufilterid NUMBER;
    price B2B_MAIN.object_price.obp_amt%TYPE;
  BEGIN
    FOR subasstrel IN
    (SELECT         *
        FROM B2B_MAIN.relationship
        WHERE rel_parent_id = asstID
        AND version         = versionnum
        AND rel_status_cd   = 'A'
        ORDER BY rel_priority
    )
    LOOP
      SELECT COUNT(*)
          INTO rows
          FROM B2B_MAIN.V_ASSORTMENT
          WHERE ast_id      = subasstrel.rel_child_id
          AND version       = versionnum
          AND ast_status_cd = 'A';
 
      IF rows > 0 THEN
        SELECT ast_label
            INTO asstname
            FROM B2B_MAIN.V_ASSORTMENT
            WHERE ast_id                    = subasstrel.rel_child_id
            AND version                     = versionnum
            AND ast_status_cd               = 'A';
 
        resultoutput(rowindex).subasst := asstname;
        skufilterid                    := getSKUFilterID(subasstrel.rel_child_id);
 
        FOR prodrel                    IN
        (SELECT                         *
            FROM B2B_MAIN.relationship
            WHERE rel_parent_id = subasstrel.rel_child_id
            AND version         = versionnum
            AND rel_status_cd   = 'A'
            ORDER BY rel_priority
        )
        LOOP
          price                           := getProductPrice(prodrel.rel_child_id);
          resultoutput(rowindex).product  := prodrel.rel_nm;
          resultoutput(rowindex).prdprice := price;
 
          IF SKUFILTERID = 0 THEN
            -- if the assortment does NOT have a sub assortment named 'SKUFilter'
            -- print out all available skus for the product
            printProductDetails(prodrel.rel_child_id);
          ELSE
            rows := isPrdFiltered(prodrel.rel_child_id, skufilterid);
            IF rows = 0 THEN
              -- if the assortment does have a sub assortment named 'SKUFilter'
              -- but this product is NOT in SKUFilter
              -- print out all available skus for the product
              printProductDetails(prodrel.rel_child_id);
            ELSE
              -- if the assortment does have a sub assortment named 'SKUFilter'
              -- but this product is SKUFiltered
              -- print out only the skus on SKUFilter.
              pritnProductDetailsInSKUFilter(prodrel.rel_child_id, skufilterid);
            END IF;
          END IF;
        END LOOP;
      END IF;
    END LOOP;
  END DISPLAYASSTPROD;
 
  -- return the price for a given product id
  -- in some cases, the product does not have a price. this function is to make
  -- sure the process does not break by capture the exception no_data_found
  FUNCTION getProductPrice(objID IN NUMBER) RETURN B2B_MAIN.OBJECT_PRICE.OBP_AMT%TYPE AS
    price B2B_MAIN.OBJECT_PRICE.OBP_AMT%TYPE;
  BEGIN
    SELECT obp_amt
      INTO price
      FROM B2B_MAIN.OBJECT_PRICE
      WHERE obp_obj_id = objID
      AND version      = versionnum
      AND OBP_PRL_ID   = PRICELISTID;
 
    RETURN price;
 
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RETURN 0.00;
  END getProductPrice;
 
  -- to tell if a given assortment has 'SKUFilter' set
  -- return the SKUFilter sub assortment id or
  -- 0 if none is found
  FUNCTION getSKUFilterID(asstID IN VCHAR2) RETURN NUMBER  AS
    subAsstID NUMBER := 0;
  BEGIN
    SELECT sba_id
        INTO subAsstID
        FROM B2B_MAIN.v_sub_assortment
        WHERE sba_nm      = 'SKUFilter'
        AND sba_parent_id = asstID
        AND version       = versionnum
        AND sba_status_cd = 'A';
 
    RETURN subAsstID;
 
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RETURN 0;
  END getSKUFilterID;
 
  PROCEDURE printProductDetails(prdID IN NUMBER) AS
    CURSOR prddetailscursor IS
      SELECT sku.sku_id,
        sku.sku_code,
        sku.sku_upc,
        cl.oba_str_val cl_code,
        cld.dmv_label cl_label,
        sz.oba_str_val sz_code,
        szd.dmv_label sz_label
      FROM B2B_MAIN.sku sku
      LEFT JOIN B2B_MAIN.object_attribute cl
      ON cl.version     = versionnum
      AND cl.oba_obj_id = sku.sku_id
      AND cl.oba_atr_id = colorAtrID
      LEFT JOIN B2B_MAIN.DOMAIN_VALUE cld
      ON cld.version        = versionnum
      AND cld.dmv_status_cd = 'A'
      AND cld.dmv_dom_id    = colorDomID
      AND cld.DMV_STR_VAL   = cl.oba_str_val
      LEFT JOIN B2B_MAIN.object_attribute sz
      ON sz.version     = versionnum
      AND sz.oba_obj_id = sku.sku_id
      AND sz.oba_atr_id = sizeAtrID
      LEFT JOIN B2B_MAIN.DOMAIN_VALUE szd
      ON szd.version          = versionnum
      AND szd.dmv_status_cd   = 'A'
      AND szd.dmv_dom_id      = sizeDomID
      AND szd.DMV_STR_VAL     = sz.oba_str_val
      WHERE sku.sku_parent_id = prdID
      AND sku.version         = versionnum
      AND sku.sku_status_cd   = 'A'
      ORDER BY cld.dmv_seq, szd.dmv_seq;
 
    prddetails prddetailscursor%ROWTYPE;
    rows INTEGER;
    price B2B_MAIN.object_price.obp_amt%TYPE;
  BEGIN
    resultoutput(rowindex).filtered := 'NOFILTER';
    FOR prddetails IN prddetailscursor
    LOOP
      SELECT COUNT(*)
          INTO rows
          FROM B2B_MAIN.object_price
          WHERE obp_obj_id = prddetails.sku_id
          AND version      = versionnum
          AND obp_prl_id   = pricelistID;
 
      IF rows = 1 THEN
        -- if the sku has a price to overwrite the parent product price
        SELECT obp_amt
            INTO price
            FROM B2B_MAIN.object_price
            WHERE obp_obj_id                       = prddetails.sku_id
            AND version                            = versionnum
            AND obp_prl_id                         = pricelistID;
        resultoutput(rowindex).color          := prddetails.cl_label;
        resultoutput(rowindex).thsize         := prddetails.sz_label;
        resultoutput(rowindex).upc            := prddetails.sku_upc;
        resultoutput(rowindex).priceoverwrite := price;
      ELSE
        -- if the sku does NOT have a price to overwrite the parent product price
        resultoutput(rowindex).color  := prddetails.cl_label;
        resultoutput(rowindex).thsize := prddetails.sz_label;
        resultoutput(rowindex).upc    := prddetails.sku_upc;
      END IF;
      resultoutput.extend;
      rowindex := rowindex + 1;
    END LOOP;
  END printProductDetails;
 
  FUNCTION isPrdFiltered(prdID IN NUMBER, skuFilterID IN NUMBER) RETURN NUMBER AS
    rows NUMBER;
  BEGIN
    SELECT COUNT(*)
        INTO rows
        FROM B2B_MAIN.relationship rel,
          B2B_MAIN.sku sku,
          B2B_MAIN.product prd
        WHERE rel.rel_parent_id = skuFilterID
        AND rel.version         = versionnum
        AND rel.rel_status_cd   = 'A'
        AND rel.rel_child_id    = sku.sku_id
        AND sku.version         = versionnum
        AND sku.sku_status_cd   = 'A'
        AND sku.sku_parent_id   = prd.prd_id
        AND prd.version         = versionnum
        AND prd.prd_status_cd   = 'A'
        AND prd.prd_id          = prdID;
 
    RETURN rows;
  END isPrdFiltered;
 
  PROCEDURE pritnProductDetailsInSKUFilter(prdID IN NUMBER, skuFilterID IN NUMBER) AS
    CURSOR skucursor IS
      SELECT sku.sku_id,
        cl.oba_str_val cl_code,
        cld.dmv_label cl_label,
        sz.oba_str_val sz_code,
        szd.dmv_label sz_label,
        sku.sku_upc
      FROM B2B_MAIN.relationship rel,
        B2B_MAIN.sku sku,
        B2B_MAIN.product prd,
        B2B_MAIN.object_attribute cl,
        B2B_MAIN.DOMAIN_VALUE cld,
        B2B_MAIN.object_attribute sz,
        B2B_MAIN.DOMAIN_VALUE szd
      WHERE rel.rel_parent_id = skuFilterID
      AND rel.version         = versionnum
      AND rel.rel_status_cd   = 'A'
      AND rel.rel_child_id    = sku.sku_id
      AND sku.version         = versionnum
      AND sku.sku_status_cd   = 'A'
      AND sku.sku_parent_id   = prd.prd_id
      AND prd.version         = versionnum
      AND prd.prd_status_cd   = 'A'
      AND prd.prd_id          = prdID
      AND cl.version          = versionnum
      AND cl.oba_obj_id       = sku.sku_id
      AND cl.oba_atr_id       = colorAtrID
      AND cld.version         = versionnum
      AND cld.dmv_status_cd   = 'A'
      AND cld.dmv_dom_id      = colorDomID
      AND cld.DMV_STR_VAL     = cl.oba_str_val
      AND sz.version          = versionnum
      AND sz.oba_obj_id       = sku.sku_id
      AND sz.oba_atr_id       = sizeAtrID
      AND szd.version         = versionnum
      AND szd.dmv_status_cd   = 'A'
      AND szd.dmv_dom_id      = sizeDomID
      AND szd.DMV_STR_VAL     = sz.oba_str_val
      ORDER BY cld.dmv_seq, szd.dmv_seq;
 
    skuid skucursor%ROWTYPE;
    rows INTEGER;
    price B2B_MAIN.object_price.obp_amt%TYPE;
  BEGIN
    resultoutput(rowindex).filtered := 'SKUFILTERED';
    FOR skuid IN skucursor
    LOOP
      SELECT COUNT(*)
          INTO rows
          FROM B2B_MAIN.object_price
          WHERE obp_obj_id = skuid.sku_id
          AND version      = versionnum
          AND obp_prl_id   = pricelistID;
 
      IF rows = 1 THEN
        -- the sku has a price to overwrite product price
        SELECT obp_amt
          INTO price
          FROM B2B_MAIN.object_price
          WHERE obp_obj_id                       = skuid.sku_id
          AND version                            = versionnum
          AND obp_prl_id                         = pricelistID;
 
        resultoutput(rowindex).color          := skuid.cl_label;
        resultoutput(rowindex).thsize         := skuid.sz_label;
        resultoutput(rowindex).upc            := skuid.sku_upc;
        resultoutput(rowindex).priceoverwrite := price;
      ELSE
        -- the sku does not have a price to overwrite product price
        resultoutput(rowindex).color  := skuid.cl_label;
        resultoutput(rowindex).thsize := skuid.sz_label;
        resultoutput(rowindex).upc    := skuid.sku_upc;
      END IF;
      resultoutput.extend;
      rowindex := rowindex + 1;
    END LOOP;
  END pritnProductDetailsInSKUFilter;
 
  PROCEDURE getAtrIDDomIDFor(atrNM IN VCHAR2, atrID OUT NUMBER, domID OUT NUMBER) AS
  BEGIN
    SELECT atr_id,
          atr_dom_id
        INTO atrID,
          domID
        FROM B2B_MAIN.attribute
        WHERE atr_nm      = atrNM
        AND version       = versionnum
        AND ATR_STATUS_CD = 'A';
 
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
      DBMS_OUTPUT.put_line('Can not find atr id for attribute: ' || atrNM);
      atrID := 0;
      domID := 0;
  END getAtrIDDomIDFor;
 
  PROCEDURE formatoutput AS
    curbse B2B_STORE.BUSINESS_ENTITY.bse_login_nm%TYPE;
    curorg B2B_STORE.v_organization.org_label%TYPE;
    cursubasst B2B_MAIN.V_ASSORTMENT.ast_label%TYPE;
    curproduct B2B_MAIN.product.prd_code%TYPE;
    curprdprice B2B_MAIN.object_price.obp_amt%TYPE;
    curfiltered VCHAR2(20);
    tempbse B2B_STORE.business_entity.bse_login_nm%TYPE;
    temporg B2B_STORE.v_organization.org_label%TYPE;
    tempsubasst B2B_MAIN.V_ASSORTMENT.ast_label%TYPE;
    tempproduct B2B_MAIN.product.prd_code%TYPE;
    tempprdprice B2B_MAIN.object_price.obp_amt%TYPE;
    tempfiltered VCHAR2(20);
  BEGIN
    DBMS_OUTPUT.put_line('"Company","Orgnization","Sub Assortment","Product Code","Product Price","Filtered","Color","Size","UPC","SKU Price Overwrite"');
    FOR n IN resultoutput.FIRST .. resultoutput.LAST - 1
    LOOP
      tempbse      := resultoutput(n).bse;
      temporg      := resultoutput(n).org;
      tempsubasst  := resultoutput(n).subasst;
      tempproduct  := resultoutput(n).product;
      tempprdprice := resultoutput(n).prdprice;
      TEMPFILTERED := RESULTOUTPUT(N).FILTERED;
 
      IF tempbse   IS NULL THEN
        tempbse    := curbse;
      ELSE
        curbse := tempbse;
      END IF;
 
      IF temporg IS NULL THEN
        temporg  := curorg;
      ELSE
        curorg := temporg;
      END IF;
 
      IF tempsubasst IS NULL THEN
        tempsubasst  := cursubasst;
      ELSE
        cursubasst := tempsubasst;
      END IF;
 
      IF tempproduct IS NULL THEN
        tempproduct  := curproduct;
        tempprdprice := curprdprice;
        tempfiltered := curfiltered;
      ELSE
        curproduct  := tempproduct;
        curprdprice := tempprdprice;
        curfiltered := tempfiltered;
      END IF;
 
      DBMS_OUTPUT.put_line(
        '"' || tempbse || '",' ||
        '"' || temporg || '",' ||
        '"' || tempsubasst || '",' ||
        '"' || tempproduct || '",' ||
        '"' || tempprdprice || '",' ||
        '"' || tempfiltered || '",' ||
        '"' || resultoutput(n).color || '",' ||
        '"' || resultoutput(n).thsize || '",' ||
        '"' || resultoutput(n).upc || '",' ||
        '"' || resultoutput(n).priceoverwrite || '"'
        );
    END LOOP;
  END formatoutput;
END TWINHILLUTIL;

PL/SQL

Perl: 2yrs

Perl Code Example - File Process

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl
 
#-----------------------------------------------------------------------------------------#
# How to use this script:
#      perl getallowadj.pl -i read_from_file_name -o write_to_file_name -b business_entity
#-----------------------------------------------------------------------------------------#
 
require 5.008004;
use strict;
use Getopt::Std;
 
 
my $procTime = localtime();
my $expDate;
my %opts;
my $inputFile;
my $outputFile;
my $busEntity;
my $field;
 
getopt("iob", %opts);      # Where i = input file <required>
                     #       o = output file <required>
                     #       b = business entity label
 
$inputFile = $opts{'i'};
$outputFile = $opts{'o'};
$busEntity = $opts{'b'};
 
if (($inputFile eq "") || ($outputFile eq "") || ($busEntity eq "")) {
   die "Incorrect usage:n-i inputFile, -o outputFile, and -b businessEntity are required.n";
}
 
 
#*****************************************************************************#
#    MAIN PROGRAM LOGIC                                                       #
#*****************************************************************************#
 
open ALLOWANCEINPUT, "<$inputFile" or die "Can not open file "$inputFile" to read: $!";
open ALLOWANCEOUTPUT, ">$outputFile" or die "Can not open file "$outputFile" to write: $!";
 
print ALLOWANCEOUTPUT "<?xml version="1.0" encoding="UTF-8"?>n";
print ALLOWANCEOUTPUT "<adjustments xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ";
print ALLOWANCEOUTPUT "xsi:noNamespaceSchemaLocation="twh_allowance_v1.xsd">n";
 
while (<allowanceinput>) {
   my @fields = split(/|/);
   if (scalar @fields > 40) {
 
      foreach $field (@fields) {
         $field = trim($field);
      }
 
      # If date or amount are defined
      if ( $fields[37] || $fields[39] ) {
 
         print ALLOWANCEOUTPUT "    <adjustment>n";
         print ALLOWANCEOUTPUT "        <client>$busEntity</client>n";
         print ALLOWANCEOUTPUT "        <user_id>$fields[1]</user_id>n";
 
         if ($fields[37])
         {
            print ALLOWANCEOUTPUT "        <amount_adj>n";
            print ALLOWANCEOUTPUT "            <amount_adj_action>N</amount_adj_action>n";
            print ALLOWANCEOUTPUT "            <amount_adj_amount>$fields[37]</amount_adj_amount> n";
            print ALLOWANCEOUTPUT "            <amount_adj_reason><![CDATA[Generated from file $inputFile at $procTime.]]></amount_adj_reason>n";
            print ALLOWANCEOUTPUT "        </amount_adj>n";
         }
         if ($fields[39])
         {
            $expDate = '20' . substr($fields[39],0,2) . '-' . substr($fields[39],2,2) . '-' . substr($fields[39],4,2);
            print ALLOWANCEOUTPUT "        <expiration_adj>n";
            print ALLOWANCEOUTPUT "            <expiration_adj_date>$expDate</expiration_adj_date>n";
            print ALLOWANCEOUTPUT "            <expiration_adj_reason><![CDATA[Generated from file $inputFile at $procTime.]]></expiration_adj_reason>n";
            print ALLOWANCEOUTPUT "        </expiration_adj>n";
         }
 
         print ALLOWANCEOUTPUT "    </adjustment>n";
      }
   }
}
 
print ALLOWANCEOUTPUT "</adjustments>n";
 
close ALLOWANCEINPUT;
close ALLOWANCEOUTPUT;
 
 
# END MAIN PROGRAM
 
sub trim($) {
   my $string = shift;
   $string =~ s/^s+//;
   $string =~ s/s+$//;
   return $string;
}

Perl Code Example - CGI

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!c:/perl/bin/perl.exe -w
 
use CGI qw(:standard);
use CGI::Carp qw/fatalsToBrowser/;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
 
#######################################################################
# get parameters from browser and prepare to connect to target server #
#######################################################################
my $query = new CGI;
my $targetServer = $query->param('server');
my $testUser = $query->param('userid');
my $thisServer = $ENV{'SERVER_NAME'};
 
open PUNCHOUT_INIT, "post.xml" or die $!;
 
my $request = new HTTP::Request 'POST', 'https://' . $targetServer . '/cXML_requests.xml';
$request->header('Content-type', 'text/xml; charset=ISO-8859-1');
 
my $newUser = "<identity>" . $testUser . '</identity>';
while (my $xmlLine = <punchout_INIT>) {
	$xmlLine =~ s/<identity>CHICH</Identity>/$newUser/;
	$xmlLine =~ s/<url>http://localhost/cgi-bin/post.pl</URL>/<url>https://$thisServer/cgi-bin/post.pl?fromserver=$targetServer</URL>/;
	$request->add_content($xmlLine);
}
 
close PUNCHOUT_INIT;
 
############################################################
# connect to the server and send output back to browser #
############################################################
my $ua = new LWP::UserAgent;
my $response = $ua->request($request);
 
print "Content-type: text/xmlnn";
my $result = $response->content();
 
$result =~ s/&/&amp;/g;
print $result;

Perl Code Example - XSLT & json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!c:/perl/bin/perl.exe
 
use XML::LibXSLT;
use XML::LibXML;
use CGI qw(:standard);
use CGI::Carp qw/fatalsToBrowser/;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
 
################################################################
# get parameters from browser and transfer PO xml to order xml #
################################################################
my $query = new CGI;
my $filename = $query->param('filename');
my $targetServer = $query->param('server');
 
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
 
my $source = $parser->parse_file($filename);
my $style_doc = $parser->parse_file('mkorder.xsl');
 
my $stylesheet = $xslt->parse_stylesheet($style_doc);
my $results = $stylesheet->transform($source);
 
my $htmloutput = $stylesheet->output_string($results);
 
my $request = new HTTP::Request 'POST', 'https://' . $targetServer . '/cXML_requests.xml';
$request->header('Content-type', 'text/xml; charset=ISO-8859-1');
$request->add_content($htmloutput);
 
my $ua = new LWP::UserAgent;
my $response = $ua->request($request);
my $result = $response->content();
 
$result =~ s/n//g;
$result =~ s/.*<response>(.+)</Response>.*/$1/g;
$result =~ s/"/\"/g;
 
print header('application/json');
print <<end;
{
	"outputxml": "$result"
}
end

Perl

PHP Code example

PHP Code - Process HTML output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
<?php
class PM_Html
{
   const defaultInputClass = 'defaultInput';
 
   private static function appendOptions(&$htmlStr, $options)
   {
      if (is_array($options))
      {
         foreach ($options as $key => $value)
         {
            $htmlStr .= $key . '="' . $value . '" ';
         }
      }
   }
 
   private static function appendSign(&$htmlStr, $name, $required)
   {//<span style="color: #FF0000;">*</span>
      if (PM_Error::hasErrorWith($name))
         $htmlStr .= '&nbsp;<span class="requiredSign">*</span>&nbsp;';
      elseif($required)
      {
         $htmlStr .= '&nbsp;<span class="errorSign">*</span>&nbsp;';
      }
      else
         $htmlStr .= '&nbsp;<span>&nbsp;</span>&nbsp;';
   }
 
   private static function isObject($fieldName, &$objName, &$attrName)
   {
      if (preg_match('/^(w+)[(w+)]$/', $fieldName, $result))
      {
         $objName = $result[1];
         $attrName = $result[2];
         return true;
      }
      else
      {
         return false;
      }
   }
 
 
   public static function getBody()
   {
      $outStr = '<body ';
      $bodyAttr = $GLOBALS['pmPageInfo']['body'];
      if(is_array($bodyAttr))
         self::appendOptions($outStr, $bodyAttr);
 
      $outStr .= '>';
 
      return $outStr;
   }
 
   public static function getInfoText($text)
   {
      $outStr = '<span class="infoText">' . $text . '</span>';
      return $outStr;
   }
 
   public function getFormStart($name, $action, $method, $options = null)
   {
      $outStr = '<form ';
 
      if (isset($name))
      {
         $outStr .= 'name="' . $name . '" ';
      }
 
      if (isset($action))
         $outStr .= 'action="' . $action . '" ';
      if (isset($method))
      {
         switch(strtolower($method))
         {
         case 'post':
            $outStr .= 'method="post" ';
            break;
         case 'get':
            $outStr .= 'method="get" ';
            break;
         default:
            break;
         }
      }
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= ">n";
 
      if (isset($name))
      {
         $outStr .= '<input type="hidden" name="pmForm" value="' . $name . '">';
      }
 
      return $outStr;
   }
 
   public function getFormEnd()
   {
      return '</form>';
   }
 
   public function getInput($type, $name, $value, $required = false, $options = null, $defaultClass = TRUE)
   {
      $outStr = '<input ';
      if ($defaultClass)
         $outStr .= 'class="' . self::defaultInputClass . '" ';
 
      if (isset($type))
      {
         switch(strtolower($type))
         {
         case 'text':
            $outStr .= 'type="text" ';
            break;
         case 'hidden':
            $outStr .= 'type="hidden" ';
            break;
         case 'radio':
            $outStr .= 'type="radio" ';
            break;
         case 'submit':
            $outStr .= 'type="submit" ';
            break;
         case 'password':
            $outStr .= 'type="password" ';
            break;
         case 'file':
            $outStr .= 'type="file" ';
            break;
         default:
            break;
         }
         //$outStr .= 'type="' . $type . '" ';
      }
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
 
      /*if (PM_Error::hasErrorWith($name))
         $outStr .= 'class="errored" ';
      elseif($required)
      {
         $outStr .= 'class="required" ';
      }*/
 
      if (self::isObject($name, $objName, $attrName))
      {
         if (isset($_SESSION[$objName][$attrName]))
            $outStr .= 'value="' . $_SESSION[$objName][$attrName] . '" ';
         elseif (isset($value))
            $outStr .= 'value="' . $value . '" ';
      }
      else
      {
         if (isset($_SESSION[$name]))
            $outStr .= 'value="' . $_SESSION[$name] . '" ';
         elseif (isset($value))
            $outStr .= 'value="' . $value . '" ';
      }
 
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
 
      self::appendSign($outStr, $name, $required);
 
      return $outStr;
   }
 
   public function getCheckbox($name, $value, $checked, $options = null)
   {
      $outStr = '<input type="checkbox" ';
 
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
      if (isset($value))
         $outStr .= 'value="' . $value . '" ';
 
      if (self::isObject($name, $objName, $attrName))
      {
            if (isset($_SESSION[$objName][$attrName]))
            {
                if (is_int($_SESSION[$objName][$attrName]) && $_SESSION[$objName][$attrName] > 0)
                    $outStr .= 'checked';
                elseif(is_string($_SESSION[$objName][$attrName]))
                {
                  switch($_SESSION[$objName][$attrName])
                  {
                    case 'yes':
                    case 'on':
                    case 'true':
                    case '1':
                        $outStr .= 'checked';
                        break;
                    default:
                        //
                  }
                }
            }
            elseif ($checked)
               $outStr .= 'checked ';
      }
      else
      {
            if (isset($_SESSION[$name]))
            {
                if (is_int($_SESSION[$name]) && $_SESSION[$name] > 0)
                    $outStr .= 'checked';
                elseif(is_string($_SESSION[$name]))
                {
                  switch($_SESSION[$name])
                  {
                    case 'yes':
                    case 'on':
                    case 'true':
                    case '1':
                        $outStr .= 'checked';
                        break;
                    default:
                        //
                  }
                }
            }
            elseif ($checked)
               $outStr .= 'checked ';
      }
 
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
      return $outStr;
   }
 
   /* generate a select html from a list
        $list looks like :
                $list => array(
                    0 => array(
                        0 => 'id',
                        1 => 'text',
                        )
                    1 => array(
                        0 => 'id',
                        1 => 'text',
                        )
                    2 => array(
                        0 => 'id',
                        1 => 'text',
                        )
                )
   */
   public function getSelector($name, $list, $required = null, $options = null, $prompt = null, $defaultClass = TRUE)
   {
      $outStr .= '<select ';
      if ($defaultClass)
         $outStr .= 'class="' . self::defaultInputClass . '" ';
 
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
 
      /*if (PM_Error::hasErrorWith($name))
         $outStr .= 'class="errored" ';
      elseif($required)
      {
         $outStr .= 'class="required" ';
      }*/
 
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
 
      if (isset($prompt))
        $outStr .= '<option value="0">' . $prompt . '</option>';
 
      $selected = -1;
      if (self::isObject($name, $objName, $attrName))
      {
         if (isset($_SESSION[$objName][$attrName]))
            $selected = $_SESSION[$objName][$attrName];
      }
      else
         if (isset($_SESSION[$name]))
            $selected = $_SESSION[$name];
 
      if (is_array($list) && count($list) > 0)
        foreach($list as $item)
        {
            $outStr .= '<option value="' . $item[0] . '"';
 
            if ($selected == $item[0])
                $outStr .= ' selected';
 
            $outStr .= '>' . $item[1] . '</option>';
        }
 
      $outStr .= '</select>';
 
      self::appendSign($outStr, $name, $required);
 
      return $outStr;
   }
 
   public function getBoolSpan($bool, $text)
   {//This function will generate string like <span style="text-decoration: line-through;">Hekkkkk</span>
 
        $value = TRUE;
 
        if (!isset($bool))
        {
            $value = FALSE;
        }
        else
        {
            $str = (string) $bool;
            switch ($str)
            {
              case 'on':
              case 'yes':
              case 'true':
              case 'TRUE':
              case '1':
                $value = TRUE;
                break;
              default:
                $value = FALSE;
            }
        }
 
        $outStr = '<span'; //style="text-decoration: line-through;">';
        if (!$value)
            $outStr .= ' style="text-decoration: line-through;"';
 
        $outStr .= '>' . $text . '</span>';
 
        return $outStr;
   }
 
   public function provinceSelector($name, $country = null, $required = null, $options = null, $defaultClass = TRUE)
   {
      $sqlStr = 'select zone_id, zone_name from zones';
      if (isset($country))
         $sqlStr .= " where country_id = (select country_id from countries where country_name = '$country')";
 
      $provinceList = PM_Database::execSelect($sqlStr);
 
      $outStr .= '<select ';
      if($defaultClass)
         $outStr .= 'class="' . self::defaultInputClass . '" ';
 
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
 
      /*if (PM_Error::hasErrorWith($name))
         $outStr .= 'class="errored" ';
      elseif($required)
      {
         $outStr .= 'class="required" ';
      }*/
 
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
 
      //print_r($provinceList);
      $outStr .= '<option value="0">Select province/state:</option>';
 
      $selected = -1;
      if (self::isObject($name, $objName, $attrName))
      {
         if (isset($_SESSION[$objName][$attrName]))
            $selected = $_SESSION[$objName][$attrName];
      }
      else
         if (isset($_SESSION[$name]))
            $selected = $_SESSION[$name];
 
      foreach($provinceList as $province)
      {
         $outStr .= '<option value="' . $province[0] . '"';
 
         if ($selected == $province[0])
            $outStr .= ' selected';
 
         $outStr .= '>' . $province[1] . '</option>';
      }
 
      $outStr .= '</select>';
 
      self::appendSign($outStr, $name, $required);
 
      return $outStr;
   }
 
 
   public function prioritySelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'priority', $promot, $required, $options, FALSE);
   }
 
   public function titleSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'title', $promot, $required, $options, FALSE);
   }
 
   public function genderSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'gender', $promot, $required, $options, FALSE);
   }
 
   public function countrySelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'country', $promot, $required, $options);
   }
 
   public function languageSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'language', $promot, $required, $options);
   }
 
   public function buildingtypeSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'building_type', $promot, $required, $options);
   }
 
   public function roleSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'role', $promot, $required, $options);
   }
 
   public function flooringSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'flooring', $promot, $required, $options);
   }
 
   public function directionSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'direction', $promot, $required, $options);
   }
 
   public function vendorCatSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'vendor_category', $promot, $required, $options);
   }
 
   public function serviceOrderCateSelector($name, $required = null, $options = null, $promot = null)
   {
      return self::codingSelector($name, 'service_order_category', $promot, $required, $options);
   }
 
   private static function codingSelector($name, $codeName, $promot = null, $required = null, $options = null, $defaultClass = TRUE)
   {
      $list = PM_Code::getCodeListByName($codeName);
 
      $outStr .= '<select ';
      if ($defaultClass)
         $outStr .= 'class="' . self::defaultInputClass . '" ';
 
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
 
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
 
      if (isset($promot))
      {
         $outStr .= '<option value="0">' . $promot . '</option>';
      }
 
      $selected = '';
      //PM_Debug::throwVar('_SESSION', $_SESSION);
      if (self::isObject($name, $objName, $attrName))
      {
         if (isset($_SESSION[$objName][$attrName]))
            $selected = $_SESSION[$objName][$attrName];
      }
      else
         if (isset($_SESSION[$name]))
            $selected = $_SESSION[$name];
 
      if (is_array($list) && count($list)> 0)
        foreach($list as $code => $decode)
        {
         $outStr .= '<option value="' . $code . '"';
 
         if (strcmp($selected, $code) == 0 )
            $outStr .= ' selected';
 
         $outStr .= '>' . $decode . '</option>';
        }
 
      $outStr .= '</select>';
 
      self::appendSign($outStr, $name, $required);
 
      return $outStr;
   }
 
   public function ownerBuildingSelector($name, $ownerid, $required = null, $options = null)
   {
      //$sqlStr = 'select flooring_code, flooring_name from flooring';
      return self::listSelector($name, 'building_id', 'bld_name', 'building', null, $required, $options, "owner_id = $ownerid");
   }
 
   //Add by kevin Aug 20, 2005 ==>Start
   public function unitTypeIdSelector($name, $required = null, $options = null)
   {
         //$sqlStr = 'select unit_type_id from unit_type';
         return self::listSelector($name, 'unit_type_id', 'unit_type_name', 'unit_type', null, $required, $options);
   }
   public function unitTemplateIdSelector($name, $required = null, $options = null, $promot=null, $where = null)
   {
            //$sqlStr = 'select unit_template_id from unit_template';
            return self::listSelector($name, 'unit_template_id', 'unit_template_name', 'unit_template', $promot, $required, $options, $where);
   }
 
   public function unitNumSelector($name, $required = null, $options = null, $promot=null, $where = null)
   {
               //$sqlStr = 'select unit_template_id from unit_template';
               return self::listSelector($name, 'unit_id', 'unit_number', 'unit', $promot, $required, $options, $where);
   }
   //============================>End
 
   private static function listSelector($name, $listCode, $listName, $tableName, $promot = null, $required = null, $options = null, $where = null, $defaultClass = TRUE)
   {
      $sqlStr = "SELECT $listCode, $listName FROM $tableName";
 
      if (isset($where))
        $sqlStr .= " WHERE $where";
 
      $list = PM_Database::execSelect($sqlStr);
 
      $outStr .= '<select ';
      if ($defaultClass)
         $outStr .= 'class="' . self::defaultInputClass . '" ';
 
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
 
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
 
      if (isset($promot))
      {
         $outStr .= '<option value="0">' . $promot . '</option>';
      }
 
      $selected = '';
      //PM_Debug::throwVar('_SESSION', $_SESSION);
      if (self::isObject($name, $objName, $attrName))
      {
         if (isset($_SESSION[$objName][$attrName]))
            $selected = $_SESSION[$objName][$attrName];
      }
      else
         if (isset($_SESSION[$name]))
            $selected = $_SESSION[$name];
 
      if (is_array($list) && count($list)> 0)
        foreach($list as $item)
        {
         $outStr .= '<option value="' . $item[0] . '"';
 
         //if ($selected == $language[0])
         if (strcmp($selected, $item[0]) == 0 )
            $outStr .= ' selected';
 
         $outStr .= '>' . $item[1] . '</option>';
        }
 
      $outStr .= '</select>';
 
      self::appendSign($outStr, $name, $required);
 
      return $outStr;
   }
 
   public function getTextarea($name, $value, $columns, $rows, $options = null, $defaultClass = TRUE)
   {
      $outStr = '<textarea ';
      if($defaultClass )
         $outStr .= 'class="' . self::defaultInputClass . '" ';
 
      if (isset($name))
         $outStr .= 'name="' . $name . '" ';
      if (isset($columns))
         $outStr .= 'cols="' . $columns . '" ';
      if (isset($rows))
         $outStr .= 'rows="' . $rows . '" ';
      if (isset($options))
      {
         self::appendOptions($outStr, $options);
      }
 
      $outStr .= '>';
 
      if (self::isObject($name, $objName, $attrName))
      {
            if (isset($_SESSION[$objName][$attrName]))
               $outStr .= $_SESSION[$objName][$attrName];
            elseif (isset($value))
               $outStr .= $value;
      }
      else
      {
            if (isset($_SESSION[$name]))
               $outStr .= $_SESSION[$name];
            elseif(isset($value))
               $outStr .= $value;
      }
 
 
      $outStr .= '</textarea>';
 
      return $outStr;
   }
 
   public static function getImageByID($imageID)
   {
      $image['id'] = $imageID;
      $imgObj = PMImage::createInstance($image);
      $image = $imgObj->getImageByID();
 
      $str = '<img src="' . PM_TEMPLATES_ROOT . '/util/getImage.php?image_id=' . $imageID . '" ';
      // width="460" height="160" alt="" border="0" align=""
      $str .= 'width="' . $image['width'] . '" height="' . $image['height'] . '" alt="' . $image['alt'] . '" border="0">';
 
      return $str;
   }
/*
   public static function getReqMark()
   {
      return '<img src="/images/req_small.gif">';
   }
*/
}
 
//onsubmit="return CNN_validateSearchForm(this);"
//$options = array('onsubmit' => 'return CNN_validateSearchForm(this);');
 
//$a = new PM_Html();
//echo $a->getFormStart('user', 'updateuser.php', 'POST', $options);
/*
echo PM_Html::getFormStart('usertest', 'http://192.168.2.2/property/templates/index.php?update=deleteuser', 'post', $options);
echo PM_Html::getInput('text', 'user[first_name]', 'Smith');
echo PM_Html::getInput('text', 'user[last_name]', 'Wayne');
echo PM_Html::getInput('submit', 'update', 'Update User');
echo PM_Html::getFormEnd();
*/
?>

PHP Code - HTTP Request Handler

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<?php
 
//require_once('CheckInput.php');
 
class WorkFlow{
   // for test
   //static $input = array('user_id' => '73699', 'user_first_name' => 'micha el', 'user_last_name' => 'Tian', 'request' => 'update_user');
 
   private static $work_flow;
 
   private static function initWorkFlow()
   {
         if (file_exists(CONFIG_FILE)) {
            self::$work_flow = simplexml_load_file(CONFIG_FILE);
            return true;
         }
 
         PM_Error::newError(PM_Error::SYS_ERROR, 'Can not find config.xml.', '0');
 
         return false;
   }
 
   public function go()
   {
      if (!isset(self::$work_flow))
      {
         self::initWorkFlow() || die('Failed to open config.xml.');
      }
       //PM_Debug::throwVar('_REQUEST', $_REQUEST);
       $thisFormName = $_REQUEST['pmForm'];
       //$errLever = -1;
       $nextTemplate = null;
 
       foreach (self::$work_flow->form as $form)
       {
           if (isset($form['name']) && strcmp($form['name'], $thisFormName) == 0)
           {
               $useDefault = TRUE;
               // get request
               foreach ($form->request as $request)
               {
                  if (isset($request['name']))
                  {
 
 
                     $requestName = (string) $request['name'];
                     if (isset($_REQUEST[$requestName]))
                     {
                        // submit name is found, don't use default
                        $useDefault = FALSE;
 
                        $nextTemplate = (string) $request->nextTemplate;
 
                        $this->checkField($request, $output, $remove);
 
                        // set attributes to $_SESSION
                        if (is_array($output) && count($output) > 0)
                        {
                           foreach ($output as $outKey => $outValue)
                           {
                              if (is_array($outValue))
                              {
                                if (!isset($_SESSION[$outKey]))
                                    $_SESSION[$outKey] = $outValue;
                                else
                                    $_SESSION[$outKey] = array_merge($_SESSION[$outKey],$outValue);
                              }
                              else
                                $_SESSION[$outKey] = $outValue;
                           }
                        }
 
                        // remove attributes from $_SESSION
                        if (is_array($remove) && count($remove) > 0)
                        {
                            foreach ($remove as $removeValue)
                            {
                              if ($this->isObject($removeValue, $reomveObjName, $removeAttrName))
                                unset($_SESSION[$reomveObjName][$removeAttrName]);
                             else
                                unset($_SESSION[$removeValue]);
 
                            }
                        }
 
                        if (PM_Error::hasErrorLevelLessThan(1))
                        {
                           break;
                        }
 
                        $this->validateRequest($request);
 
                        if (PM_Error::hasErrorLevelLessThan(1))
                        {
                           break;
                        }
 
                        $this->processRequest($request);
 
                        break;
                     }
                  }
               }
 
               if($useDefault)
               {
                    //PM_Debug::throwMessage('From WorkFlow.php');
                    if(isset($form->default))
                    {
                        $default = $form->default;
                        //PM_Debug::throwMessage('From WorkFlow.php 333333');
                        //PM_Debug::throwVar('default', $default);
 
                        $nextTemplate = (string) $default->nextTemplate;
 
                        $this->checkField($default, $output, $remove);
 
                        // set attributes to $_SESSION
                        if (is_array($output) && count($output) > 0)
                        {
                           foreach ($output as $outKey => $outValue)
                           {
                              if (is_array($outValue))
                              {
                                if (!isset($_SESSION[$outKey]))
                                    $_SESSION[$outKey] = $outValue;
                                else
                                    $_SESSION[$outKey] = array_merge($_SESSION[$outKey],$outValue);
                              }
                              else
                                $_SESSION[$outKey] = $outValue;
                           }
                        }
 
                        // remove attributes from $_SESSION
                        if (is_array($remove) && count($remove) > 0)
                        {
                            foreach ($remove as $removeValue)
                            {
                              if ($this->isObject($removeValue, $reomveObjName, $removeAttrName))
                                unset($_SESSION[$reomveObjName][$removeAttrName]);
                             else
                                unset($_SESSION[$removeValue]);
 
                            }
                        }
 
                        if (!PM_Error::hasErrorLevelLessThan(1))
                        {
                            $this->validateRequest($default);
 
                            if (!PM_Error::hasErrorLevelLessThan(1))
                                $this->processRequest($default);
                        }
                    }
               }
 
               break;
           }
       }
 
       if (PM_Error::hasErrorLevelLessThan(0))
       {
         $_SESSION['pmRedirected'] = true;
         header('Location: http://' . $_SERVER['HTTP_HOST'] . ERROR_PAGE);
         exit();
       }
       else
       {
         if (PM_Error::hasErrorLevelLessThan(1))
         {
            $_SESSION['pmRedirected'] = true;
            if (isset($_SERVER['HTTP_REFERER']))
               header('Location: ' . $_SERVER['HTTP_REFERER']);
            else
               header('Location: http://' . $_SERVER['HTTP_HOST'] . ERROR_PAGE);
            exit();
         }
         else
         {
            if(isset($nextTemplate) && (strcmp($nextTemplate, basename($_SERVER['PHP_SELF'])) != 0))
            {
               $_SESSION['pmRedirected'] = true;
               header('Location: http://' . $_SERVER['HTTP_HOST'] . PM_TEMPLATES_ROOT . '/' . $nextTemplate);
               exit();
            }
         }
       }
   }
 
   private function checkField($request, &$output, &$remove)
   {
      // start to check filed
      $expect = $request->expect;
      if(!isset($expect->field))
        return;
 
      foreach ($expect->field as $field)
      {
         $fieldAttr = $field->attributes();
         $fieldNames = (string) $field;
         $fieldNameArray = explode(',', $fieldNames);
         $pattern = null;
         if (isset($fieldAttr['pattern']))
            $pattern = (string) $fieldAttr['pattern'];
         $required = isset($fieldAttr['required']);
 
         for ($i = 0; $i < count($fieldNameArray); $i++)
         {
            $fieldName = trim($fieldNameArray[$i]);
            if (strlen($fieldName) > 0)
            {
               if($this->isObject($fieldName, $objName, $attrName))
               {
                  $this->checkObj($objName, $attrName, $pattern, $required, $output, $remove);
               }
               else
               {
                  $this->checkStr($fieldName, $pattern, $required, $output, $remove);
               }
            }// end of if (strlen($fieldName) > 0)
         }// end of foreach (i = 0; i < count($fieldNameArray); i++)
      }// end of foreach ($expect->field as $field)
   }
 
   private function checkObj($objName, $attrName, $pattern, $required, &$output, &$remove)
   {
      if (isset($_REQUEST[$objName][$attrName]) && strlen($_REQUEST[$objName][$attrName]) > 0)
      {
         $attrValue = $_REQUEST[$objName][$attrName];
         if (isset($pattern))
         {// check pattern
            if (CheckInput::Check($pattern, $attrValue))
            //if (CheckInput::Check($fieldAttr['pattern'], self::$input[$fieldName]))
            {
               $output[$objName][$attrName] = $attrValue;
            }
            else
            {
               $errorMsg = 'Invalidate input: <b>'. $objName . '[' . $attrName . '] => ' . $attrValue . '</b>';
               PM_Error::newError(PM_Error::REQ_ERROR, $errorMsg, 1, $objName . '[' . $attrName . ']');
               //echo "invalidate input!  " . self::$input[$fieldName] . "n";
            }
         }// end of if (isset($pattern))
         else
         {
            $output[$objName][$attrName] = $attrValue;
         }
      }
      else
      {
         $remove[] = $objName . '[' . $attrName . ']';
 
         if ($required)
         {
            $errorMsg = 'Required field: <b>'. $objName . '[' . $attrName . ']</b> is missing in REQUEST!';
            PM_Error::newError(PM_Error::REQ_ERROR, $errorMsg, 1, $objName . '[' . $attrName . ']');
         }// end of if ($required)
      }
 
   }
 
   private function checkStr($fieldName, $pattern, $required, &$output, &$remove)
   {
      if (isset($_REQUEST[$fieldName]) && strlen($_REQUEST[$fieldName]) > 0)
      {
         $fieldValue = $_REQUEST[$fieldName];
         if (isset($pattern))
         {// check pattern
            if (CheckInput::Check($pattern, $fieldValue))
            {
               //echo "ok!  " . $_REQUEST[$fieldName] . "n";
               $output[$fieldName] = $fieldValue;
            }
            else
            {
               $errorMsg = "Invalidate input: <b>$fieldName => $fieldValue</b>";
               PM_Error::newError(PM_Error::REQ_ERROR, $errorMsg, 1, $fieldName);
               //echo "invalidate input!  " . $_REQUEST[$fieldName] . "n";
            }
         }// end of if (isset($pattern))
         else
            $output[$fieldName] = $fieldValue;
      }
      else
      {
         $remove = $fieldName;
 
         if ($required)
         {
            $errorMsg = "Required field: <b>$fieldName</b> is missing in REQUEST!";
            PM_Error::newError(PM_Error::REQ_ERROR, $errorMsg, 1, $fieldName);
         }// end of if ($required)
      }
   }
 
   private function validateRequest($request)
   {
      // to go through validate processes
      $validate = $request->validate;
      if ($validate != null)
      {
         foreach ($validate->action as $xmlaction)
         {
             if (class_exists($xmlaction))
             {
                 $actName = (string) $xmlaction;
                 $action = new $actName;
                 if (class_parents($action))
                 {
                     $parents = class_parents($action);
                     //if ($parents['PM_Validate'] != null)
                     if (isset($parents['PM_Validate']))
                     {
                         $action->validate();
                     }
                     else
                     {
                         $errorMsg = "$actName is not a validation class!";
                         PM_Error::newError(PM_Error::SYS_ERROR, $errorMsg, 0);
                     }
                 }
                 else
                 {
                     $errorMsg = "$actName does not have a parent class!";
                     PM_Error::newError(PM_Error::SYS_ERROR, $errorMsg, 0);
                 }
 
             }
             else
             {
                  $errorMsg = "$xmlaction is not a defined class!";
                  PM_Error::newError(PM_Error::SYS_ERROR, $errorMsg, 0);
             }
         }
      }
   }
 
   private function processRequest($request)
   {
      // to go through bizaction processes
      $process = $request->process;
      if ($process != null)
      {
         foreach ($process->action as $xmlaction)
         {
             if (class_exists($xmlaction))
             {
                 $actName = (string) $xmlaction;
                 $action = new $actName;
                 if (class_parents($action))
                 {
                     $parents = class_parents($action);
                     if (isset($parents['PM_Bizaction']))
                     {
                         $action->execute();
                     }
                     else
                     {
                         $errorMsg = "$actName is not a bizaction class!";
                         PM_Error::newError(PM_Error::SYS_ERROR, $errorMsg, 0);
                     }
                 }
                 else
                 {
                     $errorMsg = "$actName does not have a parent class!";
                     PM_Error::newError(PM_Error::SYS_ERROR, $errorMsg, 0);
                 }
 
             }
             else
             {
                  $errorMsg = "$xmlaction is not a defined class!";
                  PM_Error::newError(PM_Error::SYS_ERROR, $errorMsg, 0);
             }
         }
      }
   }
 
  function isObject($fieldName, &$objName, &$attrName)
   {
      if (preg_match('/^(w+)[(w+)]$/', $fieldName, $result))
      {
         $objName = $result[1];
         $attrName = $result[2];
         return true;
      }
      else
      {
         return false;
      }
   }
}
 
//$ins = new WorkFlow();
//$ins->go();
?>

PHP

MySQL code example

Code generated by MySQL Workbench

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
 
 
-- -----------------------------------------------------
-- Table 'type_code'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'type_code' ;
 
CREATE  TABLE IF NOT EXISTS 'type_code' (
  'code' CHAR(3)  NOT NULL ,
  'name' VCHAR(40) NOT NULL ,
  'desc' VCHAR(256) NULL ,
  PRIMARY KEY ('code') );
 
 
-- -----------------------------------------------------
-- Table 'user'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'user' ;
 
CREATE  TABLE IF NOT EXISTS 'user' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'login_id' VCHAR(20) NOT NULL ,
  'password' VCHAR(256) NOT NULL ,
  'first_name' VCHAR(40) NOT NULL ,
  'middle_name' VCHAR(20) NULL DEFAULT NULL ,
  'last_name' VCHAR(40) NOT NULL ,
  'created_date' DATETIME NOT NULL ,
  'status' ENUM('A', 'I','D')  NULL DEFAULT 'A' ,
  'pri_phone' VCHAR(16) NULL ,
  'pri_phone_type' CHAR(3)  NULL ,
  'sec_phone' VCHAR(16) NULL ,
  'sec_phone_type' CHAR(3)  NULL ,
  'email' VCHAR(64) NOT NULL ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_pri_phone_type'
    FOREIGN KEY ('pri_phone_type' )
    REFERENCES 'type_code' ('code' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT 'fk_sec_phone_type'
    FOREIGN KEY ('sec_phone_type' )
    REFERENCES 'type_code' ('code' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);
 
CREATE INDEX 'fk_pri_phone_type' ON 'user' ('pri_phone_type' ASC) ;
 
CREATE INDEX 'fk_sec_phone_type' ON 'user' ('sec_phone_type' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'image'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'image' ;
 
CREATE  TABLE IF NOT EXISTS 'image' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'img_name' VCHAR(256) NOT NULL ,
  'img_path' VCHAR(1024) NOT NULL ,
  'img_width' INT NULL DEFAULT 10 ,
  'img_height' INT NULL DEFAULT 10 ,
  'img_desc' VCHAR(1024) NULL ,
  'img_type' VCHAR(12) NULL ,
  'img_uploaded_date' DATETIME NULL ,
  'img_owner' BIGINT(20) UNSIGNED NOT NULL ,
  'img_status' ENUM('A', 'I','D')  NOT NULL DEFAULT 'A' ,
  'img_exif' VCHAR(2048) NULL ,
  'img_ispublic' ENUM('Y','N')  NULL DEFAULT 'N' ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_{AF1793BF-0857-4730-A72A-88A3AF10750D}'
    FOREIGN KEY ('img_owner' )
    REFERENCES 'user' ('id' ));
 
CREATE INDEX 'fk_{AF1793BF-0857-4730-A72A-88A3AF10750D}' ON 'image' ('img_owner' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'category'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'category' ;
 
CREATE  TABLE IF NOT EXISTS 'category' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'cat_name' VCHAR(128) NOT NULL ,
  'cat_status' ENUM('A', 'I','D')  NOT NULL DEFAULT 'A' ,
  PRIMARY KEY ('id') );
 
 
-- -----------------------------------------------------
-- Table 'image_category'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'image_category' ;
 
CREATE  TABLE IF NOT EXISTS 'image_category' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'img_id' BIGINT(20) UNSIGNED NOT NULL ,
  'cat_id' BIGINT(20) UNSIGNED NOT NULL ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_{77F66620-9436-4219-95AB-F481DF6EA81A}'
    FOREIGN KEY ('img_id' )
    REFERENCES 'image' ('id' ),
  CONSTRAINT 'fk_image_category_cat_id'
    FOREIGN KEY ('cat_id' )
    REFERENCES 'category' ('id' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);
 
CREATE INDEX 'fk_image_category_cat_id' ON 'image_category' ('cat_id' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'config'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'config' ;
 
CREATE  TABLE IF NOT EXISTS 'config' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'config_name' VCHAR(20) NOT NULL DEFAULT 'Default' ,
  'is_current' ENUM('Y','N')  NOT NULL DEFAULT 'Y' ,
  'img_root_path' VCHAR(2048) NOT NULL ,
  'temp_id' INT NULL DEFAULT NULL ,
  'small_thumbnail_width' INT NOT NULL DEFAULT 100 ,
  'small_thumbnail_height' INT NOT NULL DEFAULT 75 ,
  'medium_thumbnail_width' INT NOT NULL DEFAULT 200 ,
  'medium_thumbnail_height' INT NOT NULL DEFAULT 150 ,
  PRIMARY KEY ('id') );
 
 
-- -----------------------------------------------------
-- Table 'address'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'address' ;
 
CREATE  TABLE IF NOT EXISTS 'address' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'line1' VCHAR(64) NOT NULL ,
  'line2' VCHAR(64) NULL DEFAULT NULL ,
  'line3' VCHAR(64) NULL DEFAULT NULL ,
  'city' VCHAR(64) NOT NULL ,
  'state_code' CHAR(2) NULL ,
  'zip_code' VCHAR(12) NULL ,
  'country_code' CHAR(3) NOT NULL DEFAULT 'USA' ,
  PRIMARY KEY ('id') );
 
 
-- -----------------------------------------------------
-- Table 'user_address'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'user_address' ;
 
CREATE  TABLE IF NOT EXISTS 'user_address' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'user_id' BIGINT(20) UNSIGNED NOT NULL ,
  'add_id' BIGINT(20) UNSIGNED NOT NULL ,
  'is_default' ENUM('Y','N')  NOT NULL DEFAULT 'N' ,
  'is_home' ENUM('Y','N')  NOT NULL DEFAULT 'Y' ,
  'is_bill' ENUM('Y','N')  NOT NULL DEFAULT 'Y' ,
  'is_ship' ENUM('Y','N')  NOT NULL DEFAULT 'N' ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_{D63C989E-358F-49F1-BE51-C94259600786}'
    FOREIGN KEY ('user_id' )
    REFERENCES 'user' ('id' ),
  CONSTRAINT 'fk_{77099076-462F-4BC6-90B7-91F072D3A3B5}'
    FOREIGN KEY ('add_id' )
    REFERENCES 'address' ('id' ));
 
CREATE INDEX 'fk_{D63C989E-358F-49F1-BE51-C94259600786}' ON 'user_address' ('user_id' ASC) ;
 
CREATE INDEX 'fk_{77099076-462F-4BC6-90B7-91F072D3A3B5}' ON 'user_address' ('add_id' ASC) ;
 
CREATE UNIQUE INDEX 'uq_user_address' ON 'user_address' ('user_id' ASC, 'add_id' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'tag'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'tag' ;
 
CREATE  TABLE IF NOT EXISTS 'tag' (
  'id' BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT ,
  'img_id' BIGINT(20) UNSIGNED NOT NULL ,
  'tags' VCHAR(256) NULL DEFAULT NULL ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_{6536B80E-6C81-465B-B0A3-8DB34236FB98}'
    FOREIGN KEY ('img_id' )
    REFERENCES 'image' ('id' ));
 
CREATE INDEX 'fk_{6536B80E-6C81-465B-B0A3-8DB34236FB98}' ON 'tag' ('img_id' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'thumbnail'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'thumbnail' ;
 
CREATE  TABLE IF NOT EXISTS 'thumbnail' (
  'id' BIGINT(20) UNSIGNED NOT NULL ,
  'img_id' BIGINT(20) UNSIGNED NOT NULL ,
  'thumb_type' CHAR(3)  NULL ,
  'thumb_path' VCHAR(1024) NOT NULL ,
  'thumb_width' INT NOT NULL ,
  'thumb_height' INT NOT NULL ,
  'thumb_created_date' DATETIME NOT NULL ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_thumbnail_img_id'
    FOREIGN KEY ('img_id' )
    REFERENCES 'image' ('id' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT 'fk_thumbnail_type_code'
    FOREIGN KEY ('thumb_type' )
    REFERENCES 'type_code' ('code' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);
 
CREATE INDEX 'fk_thumbnail_img_id' ON 'thumbnail' ('img_id' ASC) ;
 
CREATE INDEX 'fk_thumbnail_type_code' ON 'thumbnail' ('thumb_type' ASC) ;
 
CREATE UNIQUE INDEX 'uq_thumbnail_default' ON 'thumbnail' ('img_id' ASC, 'thumb_type' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'privilege_list'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'privilege_list' ;
 
CREATE  TABLE IF NOT EXISTS 'privilege_list' (
  'id' BIGINT(20) UNSIGNED NOT NULL ,
  'name' VCHAR(40) NOT NULL ,
  PRIMARY KEY ('id') );
 
CREATE UNIQUE INDEX 'name_UNIQUE' ON 'privilege_list' ('name' ASC) ;
 
 
-- -----------------------------------------------------
-- Table 'privilege'
-- -----------------------------------------------------
DROP TABLE IF EXISTS 'privilege' ;
 
CREATE  TABLE IF NOT EXISTS 'privilege' (
  'id' BIGINT(20) UNSIGNED NOT NULL ,
  'user_id' BIGINT(20) UNSIGNED NOT NULL ,
  'img_id' BIGINT(20) UNSIGNED NOT NULL ,
  'setting' BIT(64) NOT NULL ,
  PRIMARY KEY ('id') ,
  CONSTRAINT 'fk_privilege_user1'
    FOREIGN KEY ('user_id' )
    REFERENCES 'user' ('id' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT 'fk_privilege_image1'
    FOREIGN KEY ('img_id' )
    REFERENCES 'image' ('id' )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);
 
CREATE INDEX 'fk_privilege_user1' ON 'privilege' ('user_id' ASC) ;
 
CREATE INDEX 'fk_privilege_image1' ON 'privilege' ('img_id' ASC) ;
 
CREATE UNIQUE INDEX 'uq_privilege' ON 'privilege' ('user_id' ASC, 'img_id' ASC) ;
 
 
-- -----------------------------------------------------
-- Placeholder table for view 'v_thumbnail'
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS 'v_thumbnail' ('id' INT, 'thumb_name' INT, 'thumb_parent_id' INT, 'thumb_parent_path' INT, 'thumb_path' INT, 'thumb_width' INT, 'thumb_height' INT, 'thumb_desc' INT, 'thumb_parent_type' INT, 'thumb_uploaded_date' INT, 'thumb_type' INT, 'thumb_owner' INT, 'thumb_status' INT, 'thumb_exif' INT, 'thumb_created_date' INT, 'thumb_ispublic' INT);
 
-- -----------------------------------------------------
-- View 'v_thumbnail'
-- -----------------------------------------------------
DROP VIEW IF EXISTS 'v_thumbnail' ;
DROP TABLE IF EXISTS 'v_thumbnail';
CREATE  OR REPLACE VIEW 'v_thumbnail' AS
(select thumbnail.id id,
image.img_name thumb_name,
thumbnail.img_id thumb_parent_id,
image.img_path thumb_parent_path,
thumbnail.thumb_path thumb_path,
thumbnail.thumb_width thumb_width,
thumbnail.thumb_height thumb_height,
image.img_desc thumb_desc,
image.img_type thumb_parent_type,
image.img_uploaded_date thumb_uploaded_date,
thumbnail.thumb_type thumb_type,
image.img_owner thumb_owner,
image.img_status thumb_status,
image.img_exif thumb_exif,
thumbnail.thumb_created_date thumb_created_date,
image.img_ispublic thumb_ispublic
from thumbnail, image
where thumbnail.img_id = image.id
);
 
 
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
 
-- -----------------------------------------------------
-- Data for table 'type_code'
-- -----------------------------------------------------
START TRANSACTION;
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('SML', 'Small', 'small size');
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('MED', 'Medium', 'medium size');
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('LAG', 'Large', 'large size');
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('HOM', 'Home', 'home phone');
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('OFC', 'Office', 'office phone');
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('MOB', 'Mobile', 'mobile phone');
INSERT INTO 'type_code' ('code', 'name', 'desc') VALUES ('FAX', 'Fax', 'fax number');
 
COMMIT;
 
-- -----------------------------------------------------
-- Data for table 'privilege_list'
-- -----------------------------------------------------
START TRANSACTION;
INSERT INTO 'privilege_list' ('id', 'name') VALUES (1, 'View Thumbnail Only');
INSERT INTO 'privilege_list' ('id', 'name') VALUES (2, 'View Only');
INSERT INTO 'privilege_list' ('id', 'name') VALUES (3, 'Delete');
INSERT INTO 'privilege_list' ('id', 'name') VALUES (4, 'Update');
INSERT INTO 'privilege_list' ('id', 'name') VALUES (5, 'Download');
INSERT INTO 'privilege_list' ('id', 'name') VALUES (6, 'Comment');
 
COMMIT;

MySQL

jQuery code example

jQuery Code - UI & AJAX call

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var myLayout, $westAccordion, $eastAccordion; // init global vars
 
function resizeWidgets () {
	//myLayout.resizeAll();
	$westAccordion.accordion("resize");
	$eastAccordion.accordion("resize");
};
 
  $(document).ready(function() {
    myLayout = $('body').layout({
		applyDefaultStyles:		true,
		spacing_open:			4,
		north__resizable:		false,
	    north__closable:		false,
	    north__size:			75,
		north__spacing_open:	1,
		south__resizable:		true,
	    south__closable:		true,
	    south__size:			150,
		//south__spacing_open:	1,
		west__size:				300,
		west__onresize:		function () { $("#accordion1").accordion("resize"); },
		east__onresize:		function () { $("#accordion2").accordion("resize"); }
 
	});
 
	// ACCORDION - in the West pane
	$westAccordion = $("#accordion1").accordion({
		//animated: 'bounceslide' ,
		autoHeight: false,
		collapsible: true
		//icons: { 'header': 'ui-icon-circle-plus', 'headerSelected': 'ui-icon-circle-minus'}
	});
 
 
	// ACCORDION - in the East pane - in a 'content-div'
	$eastAccordion = $("#accordion2").accordion({
		//fillSpace:	true,
		autoHeight: false,
		collapsible: true,
		active:		0
	});
 
	$("input:submit").button();
 
	$("#statustabs").tabs();
 
	$("#testpunchout").click( function(e) {
		e.preventDefault();
		var myForm = $(this).parents("form");
		var userID = $(myForm).find('input[name="userselect"]:checked').val();
		if (userID == "differentuser")
		{
			userID = $(myForm).find('input[name="user"]').val();
			if (!userID || userID == "")
			{
				alert("a user name must be specified if different user is selected!");
				return;
			}
		}
		var testtarget = $(myForm).find('input[name="server"]:checked').val();
		var requestStr = "server=" + testtarget + "&userid=" + userID;
 
		// save to outputpanel for iFrame to read from
		$("#outputpanel").data("TestTarget", testtarget);
 
		 $.ajax({
			type: "POST",
			dataType: "xml",
			//contentType: "text/xml; charset=ISO-8859-1",
		    url: "/cgi-bin/TestPunchout.pl",
		    //processData: false,
		    data: requestStr,
		    success: function(xml) {
				$(xml).find('URL').each( function () {
					var aUrl = $(this).text();
					var newHTML = '<iframe src="' + aUrl + '" width="100%" height="95%" id="frameDemo"></iframe>';
					$("#outputpanel").html('connecting to ' + aUrl);
					$("#workarea").html(newHTML);
				}
				);
		   }
		 });
		}
	);
 
	$("#testMicrosites").click( function(e) {
		e.preventDefault();
		var myForm = $(this).parents("form");
		var testtarget = $(myForm).find('input[name="server"]:checked').val();
		var requestStr = "server=" + testtarget
						+ "&clientid=" + $(myForm).find('input[name="clientselect"]:checked').val();
 
		// save test target to outputpanel for iFrame to read from
		$("#outputpanel").data("TestTarget", testtarget);
 
		 $.ajax({
			type: "POST",
			dataType: "xml",
		    url: "/cgi-bin/TestMicrosites.pl",
		    //processData: false,
		    data: requestStr,
		    success: function(xml) {
				$(xml).find('targetURL').each( function () {
					var aUrl = $(this).text();
					var newHTML = '<iframe src="' + aUrl + '" width="100%" height="95%" id="frameDemo"></iframe>';
					$("#outputpanel").html('connecting to <b><u><i>' + aUrl + '</i></u></b>');
					$("#workarea").html(newHTML);
				}
				);
		   }
		 });
		}
	);
 
	$("#testGensite").click( function(e) {
		e.preventDefault();
		var myForm = $(this).parents("form");
		var testtarget = $(myForm).find('input[name="server"]:checked').val();
		var requestStr = "server=" + testtarget
						+ "&clientid=" + $(myForm).find('input[name="clientselect"]:checked').val();
 
		// save test target to outputpanel for iFrame to read from
		$("#outputpanel").data("TestTarget", testtarget);
 
		 $.ajax({
			type: "POST",
			dataType: "xml",
		    url: "/cgi-bin/TestGensite.pl",
		    //processData: false,
		    data: requestStr,
		    success: function(xml) {
				$(xml).find('targetURL').each( function () {
					var aUrl = $(this).text();
					var newHTML = '<iframe src="' + aUrl + '" width="100%" height="95%" id="frameDemo"></iframe>';
					$("#outputpanel").html('connecting to <b><u><i>' + aUrl + '</i></u></b>');
					$("#workarea").html(newHTML);
				}
				);
		   }
		 });
		}
	);
  });

jQuery/Javacript

ANT script example

build.xml - macrodef

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  <macrodef name='co'>
    <attribute name='src' description='Source name' />
    <sequential>
      <propertycopy override='true' property='tmp.folder.local'
        from='@{src}.src' />
      <propertycopy override='true' property='tmp.folder.st'
        from='@{src}.starteam.src' />
      <if>
        <isfalse value='${is.remote}' />
        <then>
			<if>
			  <isset property="@{src}.${starteam.view}.flag" />
			  <then>
			      <echo message="${tmp.folder.st} already checked out from ${starteam.view}. skip..." />
			  </then>
			  <else>
				  <stcheckout
					servername='${starteam.server}'
					serverport='${starteam.port}'
					projectname='${starteam.project}'
					viewname='${starteam.view}'
					username='${starteam.user}'
					password='${starteam.password}'
					createworkingdirs='true'
					deleteuncontrolled='false'
					recursive='${starteam.recursive}'
					rootlocalfolder='${tmp.folder.local}'
					rootstarteamfolder='${tmp.folder.st}'
					excludes='*.f4v'
					forced='${starteam.forced}' />
				  <property name="@{src}.${starteam.view}.flag" value="yes" />
			  </else>
			</if>
        </then>
      </if>
    </sequential>
  </macrodef>

ANT

Maven script example

pom.xml - Project with Multiple Modules

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?xml version="1.0" encoding="UTF-8"?>
<project>
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.twinhill.b2b</groupId>
	<artifactId>b2b</artifactId>
	<packaging>pom</packaging>
	<version>2.0</version>
	<name>B2B Apps Root</name>
	<url>http://www.twinhill.com</url>
 
	<modules>
		<module>b2bcommon</module>
		<module>gensite</module>
		<module>contact</module>
		<module>microsites</module>
		<module>ups</module>
		<module>twhhomesite</module>
		<module>gensite_webapp</module>
  </modules>
 
  <repositories>
    <repository>
      <id>Local Nexus Server</id>
      <url>http://localhost:8080/nexus/content/groups/public</url>
    </repository>
  </repositories>
 
  <properties>
     <b2b.checkout.dir>${project.parent.basedir}/checkout</b2b.checkout.dir>
	 <b2b.checkout.java.dir>${b2b.checkout.dir}/java</b2b.checkout.java.dir>
	 <b2b.checkout.buldscripts.dir>${b2b.checkout.dir}/build/scripts</b2b.checkout.buldscripts.dir>
	 <b2b.checkout.modules.dir>${b2b.checkout.dir}/modules</b2b.checkout.modules.dir>
	 <b2b.checkout.templates.dir>${b2b.checkout.dir}/templates</b2b.checkout.templates.dir>
  </properties>
 
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
   		    <groupId>barbecue</groupId>
			<artifactId>barbecue</artifactId>
			<version>1.0.6</version>
			<scope>compile</scope>
		</dependency>
		<!--
		<dependency>
			<groupId>drools-all</groupId>
			<artifactId>drools-all</artifactId>
			<version>2.0</version>
			<scope>compile</scope>
		</dependency>
		-->
		<dependency>
			<groupId>jdom</groupId>
			<artifactId>jdom</artifactId>
			<version>1.0</version>
			<scope>compile</scope>
		</dependency>
		<!--
		<dependency>
			<groupId>jms</groupId>
			<artifactId>jms</artifactId>
			<version>1.0.2a</version>
			<scope>compile</scope>
		</dependency>
		-->
		<dependency>
		  <groupId>log4j</groupId>
		  <artifactId>log4j</artifactId>
		  <version>1.2.13</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>javax.mail</groupId>
			<artifactId>mail</artifactId>
			<version>1.2</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
		  <groupId>saxpath</groupId>
		  <artifactId>saxpath</artifactId>
		  <version>1.0</version>
		  <classifier>FCS</classifier>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>MSPCommAPI</groupId>
			<artifactId>MSPCommAPI</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
		  <groupId>jce</groupId>
		  <artifactId>jce</artifactId>
		  <version>1.2.2</version>
		</dependency>
		<dependency>
		  <groupId>bcprov</groupId>
		  <artifactId>bcprov</artifactId>
		  <version>1.44</version>
		</dependency>
		<dependency>
			  <groupId>bluemartini</groupId>
			  <artifactId>martini</artifactId>
			  <version>10.1.1.12.3</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>oromatcher</groupId>
			<artifactId>oromatcher</artifactId>
			<version>2.0.2</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
		  <groupId>IMSRTRIBSpecSDK</groupId>
		  <artifactId>IMSRTRIBSpecSDK</artifactId>
		  <version></version>
		</dependency>
		<dependency>
		  <groupId>isdcrypt</groupId>
		  <artifactId>isdcrypt</artifactId>
		  <version>6.3.0.008</version>
		</dependency>
		<dependency>
		  <groupId>bea.weblogic</groupId>
		  <artifactId>weblogic</artifactId>
		  <version>9.2.3</version>
		  <scope>provided</scope>
		</dependency>
		<dependency>
		  <groupId>bea.weblogic</groupId>
		  <artifactId>webservices</artifactId>
		  <version>9.2.3</version>
		  <scope>provided</scope>
		</dependency>
		<dependency>
		  <groupId>org.apache.poi</groupId>
		  <artifactId>poi</artifactId>
		  <version>3.0</version>
		</dependency>
		<dependency>
		  <groupId>org.drools</groupId>
		  <artifactId>drools-core</artifactId>
		  <version>4.0.7</version>
		  <classifier>JBRULES-1817</classifier>
		</dependency>
		<dependency>
		  <groupId>org.drools</groupId>
		  <artifactId>drools-compiler</artifactId>
		  <version>4.0.7</version>
		</dependency>
		<dependency>
		  <groupId>taxware</groupId>
		  <artifactId>taxware</artifactId>
		  <version>6.5</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
		  <plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
			  <source>1.5</source>
			  <target>1.5</target>
			</configuration>
		  </plugin>
		</plugins>
	</build>
</project>

pom.xml - WAR Module

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>b2b</artifactId>
    <groupId>com.twinhill.b2b</groupId>
    <version>2.0</version>
  </parent>
  <groupId>com.twinhill.b2b</groupId>
  <artifactId>gensite_webapp</artifactId>
  <packaging>war</packaging>
  <name>Create war for gensite</name>
  <url>http://maven.apache.org</url>
  <build>
    <finalName>gensite</finalName>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-antrun-plugin</artifactId>
			<executions>
				<execution>
					<id>sync-templates-WEBINF-config</id>
					<phase>generate-resources</phase>
					<configuration>
						<tasks>
							<echo message="Move ${project.artifactId} templates to src" />
							<sync todir="${project.basedir}/src/main/webapp/templates/gensite" overwrite="true">
								<fileset dir="${b2b.checkout.templates.dir}/gensite" />
							</sync>
							<echo message="Move ${project.artifactId} WEB-INF to src" />
							<sync todir="${project.basedir}/src/main/webapp/WEB-INF" overwrite="true">
								<fileset dir="${b2b.checkout.modules.dir}/gensite/appserver/weblogic/gensite/gensite/WEB-INF" />
							</sync>
							<echo message="Move the base config files to src" />
							<unzip src="${b2b.checkout.modules.dir}/base_config.zip" dest="${project.basedir}/src/main/webapp/WEB-INF"/>
							<echo message="Move b2bcommon config to src" />
							<sync todir="${project.basedir}/src/main/webapp/WEB-INF/config/b2bcommon/config" overwrite="true">
								<fileset dir="${b2b.checkout.modules.dir}/b2bcommon/config" />
							</sync>
							<echo message="Move ${project.artifactId} config to src" />
							<sync todir="${project.basedir}/src/main/webapp/WEB-INF/config/gensite/config" overwrite="true">
								<fileset dir="${b2b.checkout.modules.dir}/gensite/config" />
							</sync>
						</tasks>
					</configuration>
					<goals>
						<goal>run</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		<!--
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-antrun-plugin</artifactId>
			<executions>
				<execution>
					<id>sync-WEBINF</id>
					<phase>generate-resources</phase>
					<configuration>
						<tasks>
							<echo message="Move ${project.artifactId} templates to src" />
							<sync todir="${project.basedir}/src/main/webapp/templates/gensite" overwrite="true">
								<fileset dir="${b2b.checkout.templates.dir}/gensite" />
							</sync>
						</tasks>
					</configuration>
					<goals>
						<goal>run</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		-->
		<plugin>
			<groupId>com.twinhill.b2b</groupId>
			<artifactId>makeenvfiles-maven-plugin</artifactId>
			<version>1.0-SNAPSHOT</version>
			<executions>
			  <execution>
				<configuration>
				   <spreadsheet>${b2b.checkout.buldscripts.dir}/B2BEnvVariables.xls</spreadsheet>
				   <outputDirectory>c:/temp/test</outputDirectory>
				   <appNames>
						<param>b2bcommon</param>
						<param>gensite</param>
				   </appNames>
				   <targetName>backoffice</targetName>
				</configuration>
				<!-- <phase>process-resources</phase> -->
				<goals>
				  <goal>setenv</goal>
				</goals>
			  </execution>
			</executions>
		</plugin>
	</plugins>
  </build>
  <dependencies>
	<!--
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
	-->
	<dependency>
		<groupId>com.twinhill.b2b</groupId>
		<artifactId>creditauth</artifactId>
		<version>${project.version}</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>com.twinhill.b2b</groupId>
		<artifactId>b2bcommon</artifactId>
		<version>${project.version}</version>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>com.twinhill.b2b</groupId>
		<artifactId>gensite</artifactId>
		<version>${project.version}</version>
		<scope>compile</scope>
	</dependency>
  </dependencies>
</project>

Maven

Apache web server config example

httpd.conf - Header & Rewrite

# force to use HTTPS, no HTTP allowed
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
 
<ifModule mod_headers.c>
Header add P3P "CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT""
Header set X-UA-Compatible: IE=EmulateIE7
Header edit set-cookie "(?i)(;? ?secure;?)" "; secure; HttpOnly"
</ifModule>

Apache

Weblogic application server config example

WLST - Create Server & JDBC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
newServerName="MYSITE"
newAppName="MYSITE"
portNum="29010"
securePortNum="30010"
 
serverIP="192.168.1.100"
dbServer="dbserver01"
dbServiceName="dbservice"
 
 
def create_Server():
  cd('/')
  try:
    theBean = cmo.lookupServer(newServerName)
    if theBean == None:
      print "++++++++ Create new server:" + newServerName
      #edit()
      #startEdit()
      svr = cmo.createServer(newServerName)
      svr.setListenPort(int(portNum))
      svr.setListenAddress(serverIP)
      svr.setStagingMode("stage")
      svr.setStagingDirectoryName("/path/to/servers/" + newServerName + "/stage")
 
      print "++++++++ setting attributes for SSL for server: " + newServerName
      svrSSL=svr.getSSL()
      svrSSL.setEnabled(false)
      svrSSL.setListenPort(int(securePortNum))
 
      print "++++++++ setting attributes for Log for server: " + newServerName
      svrLog=svr.getLog()
      svrLog.setFileName("/path/to/log/" + newServerName + ".log")
 
      print "++++++++ setting attributes for WebServerLog for Sever: " + newServerName
      svrWebServer=svr.getWebServer()
      svrWebServerLog=svrWebServer.getWebServerLog()
      svrWebServerLog.setNumberOfFilesLimited(false)
 
      #save()
  except java.lang.UnsupportedOperationException, usoe:
    pass
  except weblogic.descriptor.BeanAlreadyExistsException,bae:
    pass
  except java.lang.reflect.UndeclaredThrowableException,udt:
    pass
 
"""
Create JDBC resources
"""
def create_jdbcresource(bmSchema, theUserName, thePassword):
  cd('/')
  try:
    jdbcDSName='com.xxxxxx.dbpool.' + newServerName + "." + bmSchema
    theBean = cmo.lookupJDBCSystemResource(jdbcDSName)
    if theBean == None:
      print "++++++++ creating JDBC resources for Server: " + newServerName + " with schema: " + bmSchema
 
      jdbcURL='jdbc:oracle:thin:@' + dbServer + ':1522:' + dbServiceName
      jdbcSR=cmo.createJDBCSystemResource(jdbcDSName)
 
      theJDBCResource = jdbcSR.getJDBCResource()
      theJDBCResource.setName(jdbcDSName)
 
      driverParams = theJDBCResource.getJDBCDriverParams()
      driverParams.setDriverName('oracle.jdbc.driver.OracleDriver')
      driverParams.setUrl(jdbcURL)
      driverParams.setPassword(thePassword)
 
      driverProperties = driverParams.getProperties()
      proper = driverProperties.createProperty("user")
      proper.setValue(theUserName)
 
      proper1 = driverProperties.createProperty("protocol")
      proper1.setValue("")
 
      connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()
      connectionPoolParams.setInitialCapacity(10)
      connectionPoolParams.setCapacityIncrement(5)
      connectionPoolParams.setShrinkFrequencySeconds(15)
      connectionPoolParams.setMaxCapacity(20)
      connectionPoolParams.setTestTableName("TWIST")
      connectionPoolParams.setRemoveInfectedConnections(false)
 
      cd('Servers/' + newServerName)
      target=cmo
 
      jdbcSR.addTarget(target)
  except java.lang.UnsupportedOperationException, usoe:
    pass
  except weblogic.descriptor.BeanAlreadyExistsException,bae:
    pass
  except java.lang.reflect.UndeclaredThrowableException,udt:
    pass
 
 
 
print "++++++++ Connecting to weblogic server"
connect('username','password','t3://servername:xxxxx')
 
edit()
startEdit()
create_Server()
save()
 
create_jdbcresource("schema1", "USERNAME1", "PASSWORD1")
save()
 
create_jdbcresource("schema2", "USERNAME2", "PASSWORD2")
save()
 
create_jdbcresource("schema3", "USERNAME3", "PASSWORD3")
save()
 
create_jdbcresource("schema4", "USERNAME4", "PASSWORD4")
save()
 
activate(block="true")
 
disconnect()

Weblogic