private String generateSQLStatementForDataInTable(
			Map<String, Set<Integer>> dataSourceToUse, String tableToWrite)
	{
		StringBuffer output = new StringBuffer();
		for (Entry<String, Set<Integer>> e : dataSourceToUse.entrySet()) {

			String curTemplateName = e.getKey();

			Set<Integer> curPageIds = e.getValue();

			//FIXME Problem - we do reuse existing ids here, but we treat template names from the pages and from revisions separately - resulting in
			if (!curTemplateName.isEmpty() && !curPageIds.isEmpty()) {
				//if template name does not have an id in the tplname-id map
				String id = "LAST_INSERT_ID()";
				if (!tplNameToTplId.containsKey(curTemplateName)) {
					output.append("INSERT INTO "
							+ GeneratorConstants.TABLE_TPLID_TPLNAME
							+ " (templateName) VALUES ('" + curTemplateName
							+ "');");
					output.append("\r\n");
				}
				else {
					//if template name has an id in the tplname-id map
					id = tplNameToTplId.get(curTemplateName).toString();
				}

				StringBuilder curValues = new StringBuilder();
				for (Integer pId : curPageIds) {
					if (curValues.length() > 0) {
						curValues.append(",");
					}
					curValues.append("(" + id + ", ");
					curValues.append(pId);
					curValues.append(")");
				}
				output.append("REPLACE INTO " + tableToWrite + " VALUES "
						+ curValues + ";");
				output.append("\r\n");

			}
		}

		return output.toString();
	}
private String generateSQLStatementForDataInTable ( Map < String , Set < Integer > > dataSourceToUse , String tableToWrite ) { StringBuffer output = new StringBuffer ( ) ; for ( Entry < String , Set < Integer > > e : dataSourceToUse . entrySet ( ) ) { String curTemplateName = e . getKey ( ) ; Set < Integer > curPageIds = e . getValue ( ) ; if ( ! curTemplateName . isEmpty ( ) && ! curPageIds . isEmpty ( ) ) { String id = "LAST_INSERT_ID()" ; if ( ! tplNameToTplId . containsKey ( curTemplateName ) ) { output . append ( "INSERT INTO " + GeneratorConstants . TABLE_TPLID_TPLNAME + " (templateName) VALUES ('" + curTemplateName + "');" ) ; output . append ( "\r\n" ) ; } else { id = tplNameToTplId . get ( curTemplateName ) . toString ( ) ; } StringBuilder curValues = new StringBuilder ( ) ; for ( Integer pId : curPageIds ) { if ( curValues . length ( ) > 0 ) { curValues . append ( "," ) ; } curValues . append ( "(" + id + ", " ) ; curValues . append ( pId ) ; curValues . append ( ")" ) ; } output . append ( "REPLACE INTO " + tableToWrite + " VALUES " + curValues + ";" ) ; output . append ( "\r\n" ) ; } } return output . toString ( ) ; }
Generate sql statement for data defined in {@code dataSourceToUse} and for table
in {@code tableToWrite}

@param dataSourceToUse
source to use for string generation
@param tableToWrite
table to use to store data
@return generated sql string