Changeset 34905 for gs2-extensions
- Timestamp:
- 2021-02-19T17:56:36+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/tipple-bridge/trunk/src/src/main/java/sqlCli.java
r34903 r34905 114 114 //remember to put in the projectId parameter instead of hardcoding it 115 115 116 /* 117 if we get up to the point where we allow boundary setting, i.e user specifies 118 between x and y number of records 119 could use an if statement to check 120 if the paramter exists or not, if it does then run a statement with those x and y 121 if not, then run a different statement without them 122 */ 123 116 117 /* Step 1: retrieve all the content items associated with the given projectId */ 118 124 119 String sql = "SELECT name, id, typeId, created from td_ContentItem where projectId="+projectID; 125 /* 126 String sql = "select td_Document.id, td_Document.content " + 127 "from td_Document, td_ContentItem, td_ContentItem_Document " + 128 "where td_ContentItem.projectId=" + projectID + " and td_ContentItem.id = 129 td_ContentItem_Document.ContentItemId " + 130 "and td_ContentItem_Document.documentId = td_Document.id;"; 131 */ 120 121 // consider usingLIMIT to get the returned results in controled batch size, rather than getting 122 // all the results at once. 123 132 124 ResultSet myResult = stmt.executeQuery(sql); 133 125 ResultSetMetaData resultMetaData = myResult.getMetaData(); … … 136 128 System.out.println(" Number of columns in table retrieved: " + dbColumn); 137 129 130 131 /* Step 2: Iterate through each content item, and retrieve the media files that content item has */ 132 133 /* The following is an example SELECT statement (for a hard-wired contentId = 333) that retrieves all the 134 images (both the original name, and the hashed 'path' that maps to the media files on the file 135 system (the contentItem itself at the time of writing was in projectID=4) */ 136 137 /* 138 SELECT mFile.filename, mFile.path 139 140 FROM td_ManagedFile AS mFile, td_ContentItem AS cItem, td_ContentItem_MediaItem AS cMediaItem, td_MediaItem AS mItem 141 142 WHERE 143 144 cItem.id = 333 145 146 And cMediaItem.contentItemId = cItem.id 147 148 and cMediaItem.mediaItemId = mItem.id 149 150 And mItem.fileId = mFile.id 151 */ 152 153 154 138 155 //create gson object and have the file write the opening bracket for valid json 139 156 Gson myGSon = new Gson(); … … 169 186 } 170 187 } 171 String dbRowAsJson = myGSon.toJson(dbRow); 172 173 //printing statements for checking output 174 // System.out.println("As normal: " + dbRow); 175 // System.out.println("===="); 176 //System.out.println("As JSON: " + anObject); 177 188 String dbRowAsJson = myGSon.toJson(dbRow); 189 190 178 191 //saving to json file 179 180 192 file.write(dbRowAsJson); 181 193
Note:
See TracChangeset
for help on using the changeset viewer.