[Notice] Announcing the End of Demo Server [Read me]
DB migration: Add exporting and importing feature
Add new feature that can be used for data migration. Only the site-admin can export and import data. Data exporting is downloading a file that contains json strings are generated by data from database. Data importing is truncating tables and inserting all data read from json strings that is in a uploaded file. CAUTION: TO KEEP DATA INTEGRITY, PLEASE PREVENT OTHER REQUESTS AND DO NOT ANYTHING ELSE WHILE DOING EXPORT/IMPORT RECOMMEND YOU THAT MAKE ENVIRONMENT THAT ONLY THE SITE-ADMIN CAN ACCESS. e.g.) stop proxy server and run the yobi on a port that only you know. Codes are based on mainly works of - Keesun Baik- Yi EungJun Tested export and import DB and version - H2 1.3.176 to MariaDB 10.1.10 - H2 1.3.176 to MySQM 5.6.28
@7ad78be926a0b25020ee0cd0ad4d9282611150a2
--- app/controllers/SiteApp.java
+++ app/controllers/SiteApp.java
... | ... | @@ -21,7 +21,9 @@ |
21 | 21 |
package controllers; |
22 | 22 |
|
23 | 23 |
import com.avaje.ebean.Page; |
24 |
+import com.fasterxml.jackson.core.JsonProcessingException; |
|
24 | 25 |
import controllers.annotation.AnonymousCheck; |
26 |
+import data.DataService; |
|
25 | 27 |
import info.schleichardt.play2.mailplugin.Mailer; |
26 | 28 |
import models.*; |
27 | 29 |
import models.enumeration.State; |
... | ... | @@ -30,13 +32,20 @@ |
30 | 32 |
import org.apache.commons.mail.EmailException; |
31 | 33 |
import org.apache.commons.mail.SimpleEmail; |
32 | 34 |
import org.eclipse.jgit.api.errors.GitAPIException; |
35 |
+import org.springframework.format.datetime.DateFormatter; |
|
33 | 36 |
import play.Configuration; |
34 | 37 |
import play.Logger; |
35 | 38 |
import play.db.ebean.Transactional; |
36 |
-import views.html.site.*; |
|
37 |
-import play.mvc.*; |
|
39 |
+import play.mvc.Controller; |
|
40 |
+import play.mvc.Http; |
|
41 |
+import play.mvc.Result; |
|
42 |
+import play.mvc.With; |
|
38 | 43 |
import utils.*; |
44 |
+import views.html.site.*; |
|
39 | 45 |
|
46 |
+import java.io.File; |
|
47 |
+import java.io.IOException; |
|
48 |
+import java.io.InputStream; |
|
40 | 49 |
import java.util.*; |
41 | 50 |
|
42 | 51 |
import static play.libs.Json.toJson; |
... | ... | @@ -44,7 +53,7 @@ |
44 | 53 |
/** |
45 | 54 |
* The Class SiteApp. |
46 | 55 |
*/ |
47 |
- @With(SiteManagerAuthAction.class) |
|
56 |
+@With(SiteManagerAuthAction.class) |
|
48 | 57 |
@AnonymousCheck |
49 | 58 |
public class SiteApp extends Controller { |
50 | 59 |
|
... | ... | @@ -279,4 +288,37 @@ |
279 | 288 |
public static Result diagnose() { |
280 | 289 |
return ok(diagnostic.render("title.siteSetting", Diagnostic.checkAll())); |
281 | 290 |
} |
291 |
+ |
|
292 |
+ public static Result data() { |
|
293 |
+ return ok(data.render("title.siteSetting")); |
|
294 |
+ } |
|
295 |
+ |
|
296 |
+ public static Result exportData() throws JsonProcessingException { |
|
297 |
+ Date date = new Date(); |
|
298 |
+ DateFormatter formatter = new DateFormatter("yyyyMMddHHmm"); |
|
299 |
+ String formattedDate = formatter.print(date, Locale.getDefault()); |
|
300 |
+ |
|
301 |
+ InputStream in = new DataService().exportData(); |
|
302 |
+ response().setContentType("application/x-download"); |
|
303 |
+ response().setHeader("Content-disposition","attachment; filename=yobi-data-" + formattedDate + ".json"); |
|
304 |
+ |
|
305 |
+ return ok(in); |
|
306 |
+ } |
|
307 |
+ |
|
308 |
+ public static Result importData() throws IOException { |
|
309 |
+ Http.MultipartFormData body = request().body().asMultipartFormData(); |
|
310 |
+ Http.MultipartFormData.FilePart yobiData = body.getFile("data"); |
|
311 |
+ if (yobiData != null) { |
|
312 |
+ File file = yobiData.getFile(); |
|
313 |
+ try { |
|
314 |
+ new DataService().importData(file); |
|
315 |
+ return redirect(routes.Application.index()); |
|
316 |
+ } catch (Exception e) { |
|
317 |
+ return badRequest(ErrorViews.BadRequest.render()); |
|
318 |
+ } |
|
319 |
+ } else { |
|
320 |
+ return redirect(routes.SiteApp.data()); |
|
321 |
+ } |
|
322 |
+ } |
|
323 |
+ |
|
282 | 324 |
} |
+++ app/data/DataService.java
... | ... | @@ -0,0 +1,259 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data; | |
20 | + | |
21 | +import com.fasterxml.jackson.annotation.JsonAutoDetect; | |
22 | +import com.fasterxml.jackson.annotation.JsonInclude; | |
23 | +import com.fasterxml.jackson.core.*; | |
24 | +import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; | |
25 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
26 | +import data.exchangers.*; | |
27 | +import org.joda.time.DateTime; | |
28 | +import org.joda.time.Duration; | |
29 | +import org.springframework.dao.CleanupFailureDataAccessException; | |
30 | +import org.springframework.jdbc.CannotGetJdbcConnectionException; | |
31 | +import org.springframework.jdbc.core.JdbcTemplate; | |
32 | +import org.springframework.stereotype.Service; | |
33 | +import play.Configuration; | |
34 | +import play.db.DB; | |
35 | + | |
36 | +import javax.sql.DataSource; | |
37 | +import java.io.*; | |
38 | +import java.sql.Connection; | |
39 | +import java.sql.DatabaseMetaData; | |
40 | +import java.sql.SQLException; | |
41 | +import java.util.ArrayList; | |
42 | +import java.util.Collections; | |
43 | +import java.util.Comparator; | |
44 | +import java.util.List; | |
45 | + | |
46 | +/** | |
47 | + * @author Keeun Baik | |
48 | + */ | |
49 | +@Service | |
50 | +public class DataService { | |
51 | + | |
52 | + private List<Exchanger> exchangers; | |
53 | + | |
54 | + private static final Comparator<Exchanger> COMPARATOR = new Comparator<Exchanger>() { | |
55 | + @Override | |
56 | + public int compare(Exchanger ex1, Exchanger ex2) { | |
57 | + return ex1.getTable().compareTo(ex2.getTable()); | |
58 | + } | |
59 | + }; | |
60 | + | |
61 | + String dataSourceName; | |
62 | + | |
63 | + public DataService() { | |
64 | + exchangers = new ArrayList<>(); | |
65 | + exchangers.add(new AssigneeDataExchanger()); | |
66 | + exchangers.add(new AttachmentDataExchanger()); | |
67 | + exchangers.add(new CommentThreadDataExchanger()); | |
68 | + exchangers.add(new CommentThreadUserDataExchanger()); | |
69 | + exchangers.add(new CommitCommentDataExchanger()); | |
70 | + exchangers.add(new EmailDataExchanger()); | |
71 | + exchangers.add(new IssueCommentDataExchanger()); | |
72 | + exchangers.add(new IssueCommentVoterDataExchanger()); | |
73 | + exchangers.add(new IssueDataExchanger()); | |
74 | + exchangers.add(new IssueEventDataExchanger()); | |
75 | + exchangers.add(new IssueIssueLabelDataExchanger()); | |
76 | + exchangers.add(new IssueLabelCategoryDataExchanger()); | |
77 | + exchangers.add(new IssueLabelDataExchanger()); | |
78 | + exchangers.add(new IssueVoterDataExchanger()); | |
79 | + exchangers.add(new LabelDataExchanger()); | |
80 | + exchangers.add(new MentionDataExchanger()); | |
81 | + exchangers.add(new MilestoneDataExchanger()); | |
82 | + exchangers.add(new NotificationEventDataExchanger()); | |
83 | + exchangers.add(new NotificationEventUserDataExchanger()); | |
84 | + exchangers.add(new NotificationMailDataExchanger()); | |
85 | + exchangers.add(new OrganizationDataExchanger()); | |
86 | + exchangers.add(new OrganizationUserDataExchanger()); | |
87 | + exchangers.add(new OriginalEmailDataExchanger()); | |
88 | + exchangers.add(new PostingCommentDataExchanger()); | |
89 | + exchangers.add(new PostingDataExchanger()); | |
90 | + exchangers.add(new ProjectDataExchanger()); | |
91 | + exchangers.add(new ProjectLabelDataExchanger()); | |
92 | + exchangers.add(new ProjectMenuDataExchanger()); | |
93 | + exchangers.add(new ProjectPushedBranchDataExchanger()); | |
94 | + exchangers.add(new ProjectTransferDataExchanger()); | |
95 | + exchangers.add(new ProjectUserDataExchanger()); | |
96 | + exchangers.add(new ProjectVisitationDataExchanger()); | |
97 | + exchangers.add(new PropertyDataExchanger()); | |
98 | + exchangers.add(new PullRequestCommitDataExchanger()); | |
99 | + exchangers.add(new PullRequestDataExchanger()); | |
100 | + exchangers.add(new PullRequestEventDataExchanger()); | |
101 | + exchangers.add(new PullRequestReviewersDataExchanger()); | |
102 | + exchangers.add(new RecentlyVisitedProjectsDataExchanger()); | |
103 | + exchangers.add(new ReviewCommentDataExchanger()); | |
104 | + exchangers.add(new RoleDataExchanger()); | |
105 | + exchangers.add(new SiteAdminDataExchanger()); | |
106 | + exchangers.add(new UnwatchDataExchanger()); | |
107 | + exchangers.add(new UserDataExchanger()); | |
108 | + exchangers.add(new UserEnrolledOrganizationDataExchanger()); | |
109 | + exchangers.add(new UserEnrolledProjectDataExchanger()); | |
110 | + exchangers.add(new UserProjectNotificationDataExchanger()); | |
111 | + exchangers.add(new WatchDataExchanger()); | |
112 | + Collections.sort(exchangers, COMPARATOR); | |
113 | + dataSourceName = Configuration.root().getString("ebeanconfig.datasource.default", "default"); | |
114 | + } | |
115 | + | |
116 | + public InputStream exportData() { | |
117 | + final DateTime start = DateTime.now(); | |
118 | + DataSource dataSource = DB.getDataSource(dataSourceName); | |
119 | + final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); | |
120 | + final String dbName = getDBName(dataSource); | |
121 | + final String catalogName = getCatalogName(dataSource); | |
122 | + ObjectMapper mapper = getObjectMapper(); | |
123 | + final JsonFactory factory = mapper.getFactory(); | |
124 | + | |
125 | + PipedInputStream in = new PipedInputStream(); | |
126 | + try { | |
127 | + final PipedOutputStream out = new PipedOutputStream(in); | |
128 | + new Thread( | |
129 | + new Runnable() { | |
130 | + public void run () { | |
131 | + try { | |
132 | + JsonGenerator generator = factory.createGenerator(out, JsonEncoding.UTF8); | |
133 | + generator.setPrettyPrinter(new DefaultPrettyPrinter()); | |
134 | + generator.writeStartObject(); | |
135 | + | |
136 | + for (Exchanger exchanger : exchangers) { | |
137 | + exchanger.exportData(dbName, catalogName, generator, jdbcTemplate); | |
138 | + } | |
139 | + | |
140 | + generator.writeEndObject(); | |
141 | + generator.close(); | |
142 | + | |
143 | + DateTime end = DateTime.now(); | |
144 | + Duration duration = new Duration(start, end); | |
145 | + play.Logger.info("Data export took {{}}", duration.getStandardSeconds()); | |
146 | + } | |
147 | + catch (IOException e) { | |
148 | + play.Logger.error("Failed to export data"); | |
149 | + } | |
150 | + } | |
151 | + } | |
152 | + ).start(); | |
153 | + return in; | |
154 | + } catch (IOException e) { | |
155 | + play.Logger.error("Failed to export data"); | |
156 | + e.printStackTrace(); | |
157 | + throw new RuntimeException(e); | |
158 | + } | |
159 | + } | |
160 | + | |
161 | + private String getCatalogName(DataSource dataSource) { | |
162 | + Connection connection = null; | |
163 | + try { | |
164 | + connection = dataSource.getConnection(); | |
165 | + return connection.getCatalog(); | |
166 | + } catch (SQLException e) { | |
167 | + throw new CannotGetJdbcConnectionException("failed to get connection", e); | |
168 | + } finally { | |
169 | + if (connection != null) { | |
170 | + try { connection.close(); } catch (SQLException e) { | |
171 | + throw new CleanupFailureDataAccessException("failed to close connection", e); | |
172 | + } | |
173 | + } | |
174 | + } | |
175 | + } | |
176 | + | |
177 | + public void importData(File file) throws IOException { | |
178 | + DateTime start = DateTime.now(); | |
179 | + ObjectMapper mapper = getObjectMapper(); | |
180 | + JsonFactory factory = mapper.getFactory(); | |
181 | + JsonParser parser = factory.createParser(file); | |
182 | + | |
183 | + JsonToken current = parser.nextToken(); | |
184 | + if (current != JsonToken.START_OBJECT) { | |
185 | + play.Logger.info("Data import failed cause of root if not an object."); | |
186 | + return; | |
187 | + } | |
188 | + | |
189 | + DataSource dataSource = DB.getDataSource(dataSourceName); | |
190 | + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); | |
191 | + String dbName = getDBName(dataSource); | |
192 | + disableReferentialIntegtiry(dbName, jdbcTemplate); | |
193 | + String message = ""; | |
194 | + try { | |
195 | + for (Exchanger exchanger : exchangers) { | |
196 | + exchanger.importData(dbName, parser, jdbcTemplate); | |
197 | + } | |
198 | + message = "Data import done. it took {{}}"; | |
199 | + } catch (Exception e) { | |
200 | + message = "Data import failed. it took {{}}"; | |
201 | + e.printStackTrace(); | |
202 | + throw new RuntimeException(e); | |
203 | + } finally { | |
204 | + enableReferentialIntegrity(dbName, jdbcTemplate); | |
205 | + DateTime end = DateTime.now(); | |
206 | + Duration duration = new Duration(start, end); | |
207 | + play.Logger.info(message, duration.getStandardSeconds()); | |
208 | + } | |
209 | + } | |
210 | + | |
211 | + private String getDBName(DataSource dataSource) { | |
212 | + Connection connection = null; | |
213 | + try { | |
214 | + connection = dataSource.getConnection(); | |
215 | + DatabaseMetaData metaData = connection.getMetaData(); | |
216 | + return metaData.getDatabaseProductName(); | |
217 | + } catch (SQLException e) { | |
218 | + throw new CannotGetJdbcConnectionException("failed to get meta data", e); | |
219 | + } finally { | |
220 | + if (connection != null) { | |
221 | + try { connection.close(); } catch (SQLException e) { | |
222 | + throw new CleanupFailureDataAccessException("failed to close connection", e); | |
223 | + } | |
224 | + } | |
225 | + } | |
226 | + } | |
227 | + | |
228 | + private void enableReferentialIntegrity(String dbName, JdbcTemplate jdbcTemplate) { | |
229 | + if (dbName.equals("H2")) { | |
230 | + for (Exchanger exchanger : exchangers) { | |
231 | + jdbcTemplate.update("ALTER TABLE " + exchanger.getTable() + " SET REFERENTIAL_INTEGRITY TRUE"); | |
232 | + } | |
233 | + jdbcTemplate.update("SET REFERENTIAL_INTEGRITY TRUE"); | |
234 | + } | |
235 | + } | |
236 | + | |
237 | + private void disableReferentialIntegtiry(String dbName, JdbcTemplate jdbcTemplate) { | |
238 | + if(dbName.equals("H2")) { | |
239 | + jdbcTemplate.update("SET REFERENTIAL_INTEGRITY FALSE"); | |
240 | + for (Exchanger exchanger : exchangers) { | |
241 | + jdbcTemplate.update("ALTER TABLE " + exchanger.getTable() + " SET REFERENTIAL_INTEGRITY FALSE"); | |
242 | + } | |
243 | + } | |
244 | + } | |
245 | + | |
246 | + private static ObjectMapper getObjectMapper() { | |
247 | + ObjectMapper mapper = new ObjectMapper(); | |
248 | + // prevent serializing null property to a json field | |
249 | + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |
250 | + // use filed access only | |
251 | + mapper.setVisibilityChecker(mapper.getSerializationConfig().getDefaultVisibilityChecker() | |
252 | + .withFieldVisibility(JsonAutoDetect.Visibility.ANY) | |
253 | + .withGetterVisibility(JsonAutoDetect.Visibility.NONE) | |
254 | + .withSetterVisibility(JsonAutoDetect.Visibility.NONE) | |
255 | + .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); | |
256 | + return mapper; | |
257 | + } | |
258 | + | |
259 | +} |
+++ app/data/DefaultExchanger.java
... | ... | @@ -0,0 +1,378 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.core.JsonParser; | |
23 | +import com.fasterxml.jackson.core.JsonToken; | |
24 | +import com.fasterxml.jackson.databind.JsonNode; | |
25 | +import org.apache.commons.io.IOUtils; | |
26 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
27 | +import org.springframework.jdbc.core.JdbcTemplate; | |
28 | +import org.springframework.jdbc.core.RowCallbackHandler; | |
29 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
30 | +import org.springframework.transaction.PlatformTransactionManager; | |
31 | +import org.springframework.transaction.TransactionStatus; | |
32 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | |
33 | +import play.Configuration; | |
34 | + | |
35 | +import javax.annotation.Nullable; | |
36 | +import java.io.IOException; | |
37 | +import java.io.Reader; | |
38 | +import java.io.StringWriter; | |
39 | +import java.sql.*; | |
40 | +import java.util.ArrayList; | |
41 | +import java.util.List; | |
42 | + | |
43 | +/** | |
44 | + * @author Keeun Baik | |
45 | + */ | |
46 | +public abstract class DefaultExchanger implements Exchanger { | |
47 | + | |
48 | + private static final int DEFAULT_BATCH_SIZE = 100; | |
49 | + private final static String DATA_BATCH_SIZE_KEY = "data.batch.size"; | |
50 | + | |
51 | + protected Long timestamp(Timestamp timestamp) { | |
52 | + if (timestamp != null) { | |
53 | + return timestamp.getTime(); | |
54 | + } | |
55 | + else { | |
56 | + return null; | |
57 | + } | |
58 | + } | |
59 | + | |
60 | + protected Long date(Date date) { | |
61 | + if (date != null) { | |
62 | + return date.getTime(); | |
63 | + } | |
64 | + else { | |
65 | + return null; | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + protected Timestamp timestamp(long time) { | |
70 | + if (time == 0l) { | |
71 | + return null; | |
72 | + } else { | |
73 | + return new Timestamp(time); | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + protected Date date(long time) { | |
78 | + if (time == 0l) { | |
79 | + return null; | |
80 | + } else { | |
81 | + return new Date(time); | |
82 | + } | |
83 | + } | |
84 | + | |
85 | + protected void setNullableLong(PreparedStatement ps, short index, JsonNode node, String column) throws SQLException { | |
86 | + if (node.get(column).isNull()) { | |
87 | + ps.setNull(index, Types.BIGINT); | |
88 | + } else { | |
89 | + ps.setLong(index, node.get(column).longValue()); | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + protected String clobString(@Nullable Clob clob) throws SQLException { | |
94 | + if (clob == null) { | |
95 | + return null; | |
96 | + } | |
97 | + Reader reader = clob.getCharacterStream(); | |
98 | + StringWriter writer = new StringWriter(); | |
99 | + try { | |
100 | + IOUtils.copy(reader, writer); | |
101 | + return writer.toString(); | |
102 | + } catch (IOException e) { | |
103 | + e.printStackTrace(); | |
104 | + return null; | |
105 | + } | |
106 | + } | |
107 | + | |
108 | + protected void setClob(PreparedStatement ps, short index, JsonNode node, String column) throws SQLException { | |
109 | + String value = node.get(column).textValue(); | |
110 | + if (value == null) { | |
111 | + ps.setNull(index, Types.CLOB); | |
112 | + } else { | |
113 | + Clob clob = ps.getConnection().createClob(); | |
114 | + clob.setString(1, value); | |
115 | + ps.setClob(index, clob); | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + /** | |
120 | + * generates VALUES part of a sql like, VALUES (?, ?, ?) | |
121 | + * | |
122 | + * @param size | |
123 | + * @return | |
124 | + */ | |
125 | + protected String values(int size) { | |
126 | + String values = "VALUES ("; | |
127 | + for(int i = 0 ; i < size - 1 ; i++) { | |
128 | + values += "?, "; | |
129 | + } | |
130 | + values += "?)"; | |
131 | + return values; | |
132 | + } | |
133 | + | |
134 | + protected void putLong(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
135 | + generator.writeFieldName(fieldName); | |
136 | + long value = rs.getLong(index); | |
137 | + if (rs.wasNull()) { | |
138 | + generator.writeNull(); | |
139 | + } else { | |
140 | + generator.writeNumber(value); | |
141 | + } | |
142 | + } | |
143 | + | |
144 | + protected void putInt(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
145 | + generator.writeFieldName(fieldName); | |
146 | + int value = rs.getInt(index); | |
147 | + if (rs.wasNull()) { | |
148 | + generator.writeNull(); | |
149 | + } else { | |
150 | + generator.writeNumber(value); | |
151 | + } | |
152 | + } | |
153 | + | |
154 | + protected void putString(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
155 | + generator.writeFieldName(fieldName); | |
156 | + String string = rs.getString(index); | |
157 | + if (string == null) { | |
158 | + generator.writeNull(); | |
159 | + } else { | |
160 | + generator.writeString(string); | |
161 | + } | |
162 | + } | |
163 | + | |
164 | + protected void putBoolean(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
165 | + generator.writeFieldName(fieldName); | |
166 | + generator.writeBoolean(rs.getBoolean(index)); | |
167 | + } | |
168 | + | |
169 | + protected void putTimestamp(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
170 | + generator.writeFieldName(fieldName); | |
171 | + Timestamp timestamp = rs.getTimestamp(index); | |
172 | + if (timestamp == null) { | |
173 | + generator.writeNull(); | |
174 | + } else { | |
175 | + generator.writeNumber(timestamp.getTime()); | |
176 | + } | |
177 | + } | |
178 | + | |
179 | + protected void putDate(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
180 | + generator.writeFieldName(fieldName); | |
181 | + Date date = rs.getDate(index); | |
182 | + if (date == null) { | |
183 | + generator.writeNull(); | |
184 | + } else { | |
185 | + generator.writeNumber(date.getTime()); | |
186 | + } | |
187 | + } | |
188 | + | |
189 | + protected void putClob(JsonGenerator generator, String fieldName, ResultSet rs, short index) throws SQLException, IOException { | |
190 | + generator.writeFieldName(fieldName); | |
191 | + String clobString = clobString(rs.getClob(index)); | |
192 | + if (clobString == null) { | |
193 | + generator.writeNull(); | |
194 | + } else { | |
195 | + generator.writeString(clobString); | |
196 | + } | |
197 | + } | |
198 | + | |
199 | + public void exportData(String dbName, String catalogName, final JsonGenerator generator, JdbcTemplate jdbcTemplate) throws IOException { | |
200 | + generator.writeFieldName(getTable()); | |
201 | + generator.writeStartArray(); | |
202 | + final int[] rowCount = {0}; | |
203 | + jdbcTemplate.query(getSelectSql(), new RowCallbackHandler() { | |
204 | + @Override | |
205 | + public void processRow(ResultSet rs) throws SQLException { | |
206 | + try { | |
207 | + generator.writeStartObject(); | |
208 | + setNode(generator, rs); | |
209 | + generator.writeEndObject(); | |
210 | + rowCount[0]++; | |
211 | + } catch (Exception e) { | |
212 | + e.printStackTrace(); | |
213 | + throw new RuntimeException(e); | |
214 | + } | |
215 | + } | |
216 | + }); | |
217 | + generator.writeEndArray(); | |
218 | + play.Logger.info("exported {{}} {}", rowCount[0], getTable()); | |
219 | + | |
220 | + if (hasSequence()) { | |
221 | + String sequenceName = sequenceName(); | |
222 | + long sequenceValue = 0; | |
223 | + if (dbName.equalsIgnoreCase("MySQL")) { | |
224 | + String sql = String.format("SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES " + | |
225 | + "WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'", catalogName, getTable()); | |
226 | + sequenceValue = jdbcTemplate.queryForObject(sql, Long.class); | |
227 | + } else if (dbName.equalsIgnoreCase("H2")) { | |
228 | + sequenceValue = jdbcTemplate.queryForObject("CALL NEXT VALUE FOR " + sequenceName, Long.class); | |
229 | + } | |
230 | + generator.writeFieldName(sequenceName); | |
231 | + generator.writeNumber(sequenceValue); | |
232 | + play.Logger.info("exported sequence {{}}", sequenceName()); | |
233 | + } | |
234 | + } | |
235 | + | |
236 | + public void importData(String dbName, JsonParser parser, JdbcTemplate jdbcTemplate) throws IOException { | |
237 | + PlatformTransactionManager tm = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
238 | + TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition()); | |
239 | + | |
240 | + try { | |
241 | + if (dbName.equals("MySQL")) { | |
242 | + jdbcTemplate.update("SET FOREIGN_KEY_CHECKS = 0"); | |
243 | + jdbcTemplate.update("SET NAMES \'utf8mb4\'"); | |
244 | + } | |
245 | + | |
246 | + final Configuration config = Configuration.root(); | |
247 | + int batchSize = config.getInt(DATA_BATCH_SIZE_KEY, DEFAULT_BATCH_SIZE); | |
248 | + if (parser.nextToken() != JsonToken.END_OBJECT) { | |
249 | + String fieldName = parser.getCurrentName(); | |
250 | + play.Logger.debug("importing {}", fieldName); | |
251 | + if (fieldName.equalsIgnoreCase(getTable())) { | |
252 | + truncateTable(jdbcTemplate); | |
253 | + JsonToken current = parser.nextToken(); | |
254 | + if (current == JsonToken.START_ARRAY) { | |
255 | + importDataFromArray(parser, jdbcTemplate, batchSize); | |
256 | + importSequence(dbName, parser, jdbcTemplate); | |
257 | + } else { | |
258 | + play.Logger.info("Error: records should be an array: skipping."); | |
259 | + parser.skipChildren(); | |
260 | + } | |
261 | + } | |
262 | + } | |
263 | + tm.commit(ts); | |
264 | + } catch (Exception e) { | |
265 | + e.printStackTrace(); | |
266 | + tm.rollback(ts); | |
267 | + } finally { | |
268 | + if (dbName.equals("MySQL")) { | |
269 | + jdbcTemplate.update("SET FOREIGN_KEY_CHECKS = 1"); | |
270 | + } | |
271 | + } | |
272 | + } | |
273 | + | |
274 | + private void importSequence(String dbName, JsonParser parser, JdbcTemplate jdbcTemplate) throws IOException { | |
275 | + if (hasSequence()) { | |
276 | + JsonToken fieldNameToken = parser.nextToken(); | |
277 | + if (fieldNameToken == JsonToken.FIELD_NAME) { | |
278 | + String fieldName = parser.getCurrentName(); | |
279 | + if (fieldName.equalsIgnoreCase(sequenceName())) { | |
280 | + JsonToken current = parser.nextToken(); | |
281 | + if (current == JsonToken.VALUE_NUMBER_INT) { | |
282 | + long sequenceValue = parser.getNumberValue().longValue(); | |
283 | + if (dbName.equals("MySQL")) { | |
284 | + jdbcTemplate.execute("ALTER TABLE " + getTable() + " AUTO_INCREMENT = " + sequenceValue); | |
285 | + } else if (dbName.equals("H2")) { | |
286 | + jdbcTemplate.execute("ALTER SEQUENCE " + sequenceName() + " RESTART WITH " + sequenceValue); | |
287 | + } | |
288 | + } | |
289 | + } | |
290 | + } | |
291 | + play.Logger.info("imported sequence {{}}", sequenceName()); | |
292 | + } | |
293 | + } | |
294 | + | |
295 | + private void importDataFromArray(JsonParser parser, JdbcTemplate jdbcTemplate, int batchSize) throws IOException { | |
296 | + int importedNodesCount = 0; | |
297 | + final List<JsonNode> nodes = new ArrayList<>(); | |
298 | + while (parser.nextToken() != JsonToken.END_ARRAY) { | |
299 | + final JsonNode node = parser.readValueAsTree(); | |
300 | + nodes.add(node); | |
301 | + if (nodes.size() == batchSize) { | |
302 | + importedNodesCount += batchUpdate(jdbcTemplate, nodes).length; | |
303 | + nodes.clear(); | |
304 | + } | |
305 | + } | |
306 | + if (nodes.size() > 0) { | |
307 | + importedNodesCount += batchUpdate(jdbcTemplate, nodes).length; | |
308 | + } | |
309 | + play.Logger.info("imported {{}} {}", importedNodesCount, getTable()); | |
310 | + } | |
311 | + | |
312 | + private void truncateTable(JdbcTemplate jdbcTemplate) { | |
313 | + play.Logger.debug("truncate table {}", getTable()); | |
314 | + jdbcTemplate.execute("TRUNCATE TABLE " + getTable()); | |
315 | + play.Logger.debug("truncated table {}", getTable()); | |
316 | + } | |
317 | + | |
318 | + private int[] batchUpdate(JdbcTemplate jdbcTemplate, final List<JsonNode> nodes) { | |
319 | + int[] updateCounts = jdbcTemplate.batchUpdate(getInsertSql(), new BatchPreparedStatementSetter() { | |
320 | + @Override | |
321 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
322 | + setPreparedStatement(ps, nodes.get(i)); | |
323 | + } | |
324 | + | |
325 | + @Override | |
326 | + public int getBatchSize() { | |
327 | + return nodes.size(); | |
328 | + } | |
329 | + }); | |
330 | + return updateCounts; | |
331 | + } | |
332 | + | |
333 | + /** | |
334 | + * This method is used when importing data. | |
335 | + * Set a preparedStatement with a JsonNode. | |
336 | + * | |
337 | + * @param ps | |
338 | + * @param node | |
339 | + * @throws SQLException | |
340 | + * @see #importData(JsonParser, JdbcTemplate) | |
341 | + */ | |
342 | + abstract protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException; | |
343 | + | |
344 | + /** | |
345 | + * Thia method is used when exporting data. | |
346 | + * Set a node with JsonGenerator from a ResultSet. | |
347 | + * | |
348 | + * @param generator | |
349 | + * @param rs | |
350 | + * @throws IOException | |
351 | + * @throws SQLException | |
352 | + * @see #exportData(JsonGenerator, JdbcTemplate) | |
353 | + */ | |
354 | + abstract protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException; | |
355 | + | |
356 | + /** | |
357 | + * Insert sql is used when importing data. | |
358 | + * | |
359 | + * @return insertion sql | |
360 | + */ | |
361 | + abstract protected String getInsertSql(); | |
362 | + | |
363 | + /** | |
364 | + * Select sql is used when exporting data | |
365 | + * | |
366 | + * @return selection sql | |
367 | + */ | |
368 | + abstract protected String getSelectSql(); | |
369 | + | |
370 | + protected boolean hasSequence() { | |
371 | + return true; | |
372 | + } | |
373 | + | |
374 | + protected String sequenceName() { | |
375 | + return getTable() + "_SEQ"; | |
376 | + } | |
377 | + | |
378 | +} |
+++ app/data/Exchanger.java
... | ... | @@ -0,0 +1,75 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.core.JsonParser; | |
23 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
24 | +import com.fasterxml.jackson.databind.node.ArrayNode; | |
25 | +import org.springframework.jdbc.core.JdbcTemplate; | |
26 | + | |
27 | +import java.io.IOException; | |
28 | + | |
29 | +/** | |
30 | + * @author Keeun Baik | |
31 | + */ | |
32 | +public interface Exchanger { | |
33 | + | |
34 | + /** | |
35 | + * The thable name is used when exporting and importing data. | |
36 | + * YOU SHOULD RETURN DATABASE TABLE NAME NOT ENTITY NAME. | |
37 | + * | |
38 | + * @return table name | |
39 | + */ | |
40 | + String getTable(); | |
41 | + | |
42 | + /** | |
43 | + * Read data from database with {@code jdbcTemplate} | |
44 | + * and write it as json with {@code generator}. | |
45 | + * | |
46 | + * You should make a json with a field name and an array. like: | |
47 | + * {"users": [{"id":1, "loginId":"keesun}, {"id":2, "loginId":"doortts"}]} | |
48 | + * | |
49 | + * The field name should be a table name and an entity inside the array represents a row. | |
50 | + * The one json node inside the json array, has exactly same field name and value with the row. | |
51 | + * As a result, YOU SHOULD CHANGE THE IMPLEMENTATIONS IF YOU HAVE CHANGED THE DB SCHEMA OR MAPPING. | |
52 | + * | |
53 | + * @param dbName | |
54 | + * @param generator | |
55 | + * @param jdbcTemplate | |
56 | + * @throws IOException | |
57 | + */ | |
58 | + void exportData(String dbName, String catalogName, JsonGenerator generator, JdbcTemplate jdbcTemplate) throws IOException; | |
59 | + | |
60 | + /** | |
61 | + * Read data from a {@code parser}, and write the data into database with {@code jdbcTemplate}. | |
62 | + * | |
63 | + * This operation assumes that the sequence of the json data which will be loaded by {@code parser} | |
64 | + * is exactly same with exported data with {@link #exportData(String, String, JsonGenerator, JdbcTemplate)}. | |
65 | + * | |
66 | + * YOU SHOULD BACKUP DATABASE BEFORE USING THIS OPERATION, because this operation usually | |
67 | + * truncate existing table and insert all data read from the {@code jdbcTemplate}, in some cases, | |
68 | + * you can lose all data or break referential integrity. | |
69 | + * | |
70 | + * @param parser | |
71 | + * @param jdbcTemplate | |
72 | + * @throws IOException | |
73 | + */ | |
74 | + void importData(String dbName, JsonParser parser, JdbcTemplate jdbcTemplate) throws IOException; | |
75 | +} |
+++ app/data/exchangers/AssigneeDataExchanger.java
... | ... | @@ -0,0 +1,74 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class AssigneeDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String USER_ID = "user_id"; | |
37 | + private static final String PROJECT_ID = "project_id"; | |
38 | + | |
39 | + @Override | |
40 | + protected boolean hasSequence() { | |
41 | + return true; | |
42 | + } | |
43 | + | |
44 | + @Override | |
45 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
46 | + short index = 1; | |
47 | + ps.setLong(index++, node.get(ID).longValue()); | |
48 | + ps.setLong(index++, node.get(USER_ID).longValue()); | |
49 | + ps.setLong(index++, node.get(PROJECT_ID).longValue()); | |
50 | + } | |
51 | + | |
52 | + @Override | |
53 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
54 | + short index = 1; | |
55 | + putLong(generator, ID, rs, index++); | |
56 | + putLong(generator, USER_ID, rs, index++); | |
57 | + putLong(generator, PROJECT_ID, rs, index++); | |
58 | + } | |
59 | + | |
60 | + @Override | |
61 | + public String getTable() { | |
62 | + return "ASSIGNEE"; | |
63 | + } | |
64 | + | |
65 | + @Override | |
66 | + protected String getInsertSql() { | |
67 | + return "INSERT INTO ASSIGNEE (ID, USER_ID, PROJECT_ID) " + values(3); | |
68 | + } | |
69 | + | |
70 | + @Override | |
71 | + protected String getSelectSql() { | |
72 | + return "SELECT ID, USER_ID, PROJECT_ID FROM ASSIGNEE"; | |
73 | + } | |
74 | +} |
+++ app/data/exchangers/AttachmentDataExchanger.java
... | ... | @@ -0,0 +1,91 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class AttachmentDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String NAME = "name"; | |
37 | + private static final String HASH = "hash"; | |
38 | + private static final String CONTAINER_TYPE = "content_type"; | |
39 | + private static final String MIME_TYPE = "mime_type"; | |
40 | + private static final String SIZE = "size"; | |
41 | + private static final String CONTAINER_ID = "container_id"; | |
42 | + private static final String CREATED_DATE = "created_date"; | |
43 | + | |
44 | + @Override | |
45 | + protected boolean hasSequence() { | |
46 | + return true; | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
51 | + short index = 1; | |
52 | + ps.setLong(index++, node.get(ID).longValue()); | |
53 | + ps.setString(index++, node.get(NAME).textValue()); | |
54 | + ps.setString(index++, node.get(HASH).textValue()); | |
55 | + ps.setString(index++, node.get(CONTAINER_TYPE).textValue()); | |
56 | + ps.setString(index++, node.get(MIME_TYPE).textValue()); | |
57 | + ps.setLong(index++, node.get(SIZE).longValue()); | |
58 | + ps.setString(index++, node.get(CONTAINER_ID).textValue()); | |
59 | + ps.setDate(index++, date(node.get(CREATED_DATE).longValue())); | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
64 | + short index = 1; | |
65 | + putLong(generator, ID, rs, index++); | |
66 | + putString(generator, NAME, rs, index++); | |
67 | + putString(generator, HASH, rs, index++); | |
68 | + putString(generator, CONTAINER_TYPE, rs, index++); | |
69 | + putString(generator, MIME_TYPE, rs, index++); | |
70 | + putLong(generator, SIZE, rs, index++); | |
71 | + putString(generator, CONTAINER_ID, rs, index++); | |
72 | + putDate(generator, CREATED_DATE, rs, index++); | |
73 | + } | |
74 | + | |
75 | + @Override | |
76 | + public String getTable() { | |
77 | + return "ATTACHMENT"; | |
78 | + } | |
79 | + | |
80 | + @Override | |
81 | + protected String getInsertSql() { | |
82 | + return "INSERT INTO ATTACHMENT (ID, NAME, HASH, CONTAINER_TYPE, MIME_TYPE, SIZE, CONTAINER_ID, " + | |
83 | + "CREATED_DATE) " + values(8); | |
84 | + } | |
85 | + | |
86 | + @Override | |
87 | + protected String getSelectSql() { | |
88 | + return "SELECT ID, NAME, HASH, CONTAINER_TYPE, MIME_TYPE, SIZE, CONTAINER_ID, CREATED_DATE " + | |
89 | + "FROM ATTACHMENT"; | |
90 | + } | |
91 | +} |
+++ app/data/exchangers/CommentThreadDataExchanger.java
... | ... | @@ -0,0 +1,119 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class CommentThreadDataExchanger extends DefaultExchanger { | |
34 | + private static final String DTYPE = "dtype"; | |
35 | + private static final String ID = "id"; | |
36 | + private static final String PROJECT_ID = "project_id"; | |
37 | + private static final String AUTHOR_ID = "author_id"; | |
38 | + private static final String AUTHOR_LOGIN_ID = "author_login_id"; | |
39 | + private static final String AUTHOR_NAME = "author_name"; | |
40 | + private static final String STATE = "state"; | |
41 | + private static final String COMMIT_ID = "commit_id"; | |
42 | + private static final String PATH = "path"; | |
43 | + private static final String START_SIDE = "start_side"; | |
44 | + private static final String START_LINE = "start_line"; | |
45 | + private static final String START_COLUMN = "start_column"; | |
46 | + private static final String END_SIDE = "end_side"; | |
47 | + private static final String END_LINE = "end_line"; | |
48 | + private static final String END_COLUMN = "end_column"; | |
49 | + private static final String PULL_REQUEST_ID = "pull_request_id"; | |
50 | + private static final String CREATED_DATE = "created_date"; | |
51 | + private static final String PREV_COMMIT_ID = "prev_commit_id"; | |
52 | + | |
53 | + @Override | |
54 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
55 | + short index = 1; | |
56 | + ps.setString(index++, node.get(DTYPE).textValue()); //VARCHAR nullable? 0 | |
57 | + ps.setLong(index++, node.get(ID).longValue()); //BIGINT nullable? 0 | |
58 | + ps.setLong(index++, node.get(PROJECT_ID).longValue()); //BIGINT nullable? 0 | |
59 | + setNullableLong(ps, index++, node, AUTHOR_ID); | |
60 | + ps.setString(index++, node.get(AUTHOR_LOGIN_ID).textValue()); //VARCHAR nullable? 1 | |
61 | + ps.setString(index++, node.get(AUTHOR_NAME).textValue()); //VARCHAR nullable? 1 | |
62 | + ps.setString(index++, node.get(STATE).textValue()); //VARCHAR nullable? 1 | |
63 | + ps.setString(index++, node.get(COMMIT_ID).textValue()); //VARCHAR nullable? 1 | |
64 | + ps.setString(index++, node.get(PATH).textValue()); //VARCHAR nullable? 1 | |
65 | + ps.setString(index++, node.get(START_SIDE).textValue()); //VARCHAR nullable? 1 | |
66 | + setNullableLong(ps, index++, node, START_LINE); | |
67 | + setNullableLong(ps, index++, node, START_COLUMN); | |
68 | + ps.setString(index++, node.get(END_SIDE).textValue()); //VARCHAR nullable? 1 | |
69 | + setNullableLong(ps, index++, node, END_LINE); | |
70 | + setNullableLong(ps, index++, node, END_COLUMN); | |
71 | + setNullableLong(ps, index++, node, PULL_REQUEST_ID); | |
72 | + ps.setTimestamp(index++, timestamp(node.get(CREATED_DATE).longValue())); //TIMESTAMP nullable? 1 | |
73 | + ps.setString(index++, node.get(PREV_COMMIT_ID).textValue()); //VARCHAR | |
74 | + } | |
75 | + | |
76 | + @Override | |
77 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
78 | + short index = 1; | |
79 | + putString(generator, DTYPE, rs, index++); | |
80 | + putLong(generator, ID, rs, index++); | |
81 | + putLong(generator, PROJECT_ID, rs, index++); | |
82 | + putLong(generator, AUTHOR_ID, rs, index++); | |
83 | + putString(generator, AUTHOR_LOGIN_ID, rs, index++); | |
84 | + putString(generator, AUTHOR_NAME, rs, index++); | |
85 | + putString(generator, STATE, rs, index++); | |
86 | + putString(generator, COMMIT_ID, rs, index++); | |
87 | + putString(generator, PATH, rs, index++); | |
88 | + putString(generator, START_SIDE, rs, index++); | |
89 | + putLong(generator, START_LINE, rs, index++); | |
90 | + putLong(generator, START_COLUMN, rs, index++); | |
91 | + putString(generator, END_SIDE, rs, index++); | |
92 | + putLong(generator, END_LINE, rs, index++); | |
93 | + putLong(generator, END_COLUMN, rs, index++); | |
94 | + putLong(generator, PULL_REQUEST_ID, rs, index++); | |
95 | + putTimestamp(generator, CREATED_DATE, rs, index++); | |
96 | + putString(generator, PREV_COMMIT_ID, rs, index++); | |
97 | + } | |
98 | + | |
99 | + @Override | |
100 | + public String getTable() { | |
101 | + return "COMMENT_THREAD"; | |
102 | + } | |
103 | + | |
104 | + @Override | |
105 | + protected String getInsertSql() { | |
106 | + return "INSERT INTO COMMENT_THREAD (DTYPE, ID, PROJECT_ID, AUTHOR_ID, " + | |
107 | + "AUTHOR_LOGIN_ID, AUTHOR_NAME, STATE, COMMIT_ID, PATH, START_SIDE, START_LINE, " + | |
108 | + "START_COLUMN, END_SIDE, END_LINE, END_COLUMN, PULL_REQUEST_ID, CREATED_DATE, " + | |
109 | + "PREV_COMMIT_ID) " + values(18); | |
110 | + } | |
111 | + | |
112 | + @Override | |
113 | + protected String getSelectSql() { | |
114 | + return "SELECT DTYPE, ID, PROJECT_ID, AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, " + | |
115 | + "STATE, COMMIT_ID, PATH, START_SIDE, START_LINE, START_COLUMN, END_SIDE, " + | |
116 | + "END_LINE, END_COLUMN, PULL_REQUEST_ID, CREATED_DATE, PREV_COMMIT_ID " + | |
117 | + "FROM COMMENT_THREAD"; | |
118 | + } | |
119 | +} |
+++ app/data/exchangers/CommentThreadUserDataExchanger.java
... | ... | @@ -0,0 +1,70 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class CommentThreadUserDataExchanger extends DefaultExchanger { | |
34 | + private static final String COMMENT_THREAD_ID = "comment_thread_id"; | |
35 | + private static final String N4USER_ID = "n4user_id"; | |
36 | + | |
37 | + @Override | |
38 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
39 | + short index = 1; | |
40 | + ps.setLong(index++, node.get(COMMENT_THREAD_ID).longValue()); | |
41 | + ps.setLong(index++, node.get(N4USER_ID).longValue()); | |
42 | + } | |
43 | + | |
44 | + @Override | |
45 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
46 | + short index = 1; | |
47 | + putLong(generator, COMMENT_THREAD_ID, rs, index++); | |
48 | + putLong(generator, N4USER_ID, rs, index++); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public String getTable() { | |
53 | + return "COMMENT_THREAD_N4USER"; | |
54 | + } | |
55 | + | |
56 | + @Override | |
57 | + protected String getInsertSql() { | |
58 | + return "INSERT INTO COMMENT_THREAD_N4USER (COMMENT_THREAD_ID, N4USER_ID) " + values(2); | |
59 | + } | |
60 | + | |
61 | + @Override | |
62 | + protected String getSelectSql() { | |
63 | + return "SELECT COMMENT_THREAD_ID, N4USER_ID FROM COMMENT_THREAD_N4USER"; | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + protected boolean hasSequence() { | |
68 | + return false; | |
69 | + } | |
70 | +} |
+++ app/data/exchangers/CommitCommentDataExchanger.java
... | ... | @@ -0,0 +1,95 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class CommitCommentDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; | |
35 | + private static final String PROJECT_ID = "project_id"; | |
36 | + private static final String COMMIT_ID = "commit_id"; | |
37 | + private static final String PATH = "path"; | |
38 | + private static final String LINE = "line"; | |
39 | + private static final String SIDE = "side"; | |
40 | + private static final String CREATED_DATE = "created_date"; | |
41 | + private static final String AUTHOR_ID = "author_id"; | |
42 | + private static final String AUTHOR_LOGIN_ID = "author_login_id"; | |
43 | + private static final String AUTHOR_NAME = "author_name"; | |
44 | + private static final String CONTENTS = "contents"; | |
45 | + | |
46 | + @Override | |
47 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
48 | + short index = 1; | |
49 | + ps.setLong(index++, node.get(ID).longValue()); | |
50 | + setNullableLong(ps, index++, node, PROJECT_ID); | |
51 | + ps.setString(index++, node.get(COMMIT_ID).textValue()); | |
52 | + ps.setString(index++, node.get(PATH).textValue()); | |
53 | + setNullableLong(ps, index++, node, LINE); | |
54 | + ps.setString(index++, node.get(SIDE).textValue()); | |
55 | + ps.setTimestamp(index++, timestamp(node.get(CREATED_DATE).longValue())); | |
56 | + setNullableLong(ps, index++, node, AUTHOR_ID); | |
57 | + ps.setString(index++, node.get(AUTHOR_LOGIN_ID).textValue()); | |
58 | + ps.setString(index++, node.get(AUTHOR_NAME).textValue()); | |
59 | + setClob(ps, index++, node, CONTENTS); | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
64 | + short index = 1; | |
65 | + putLong(generator, ID, rs, index++); | |
66 | + putLong(generator, PROJECT_ID, rs, index++); | |
67 | + putString(generator, COMMIT_ID, rs, index++); | |
68 | + putString(generator, PATH, rs, index++); | |
69 | + putLong(generator, LINE, rs, index++); | |
70 | + putString(generator, SIDE, rs, index++); | |
71 | + putTimestamp(generator, CREATED_DATE, rs, index++); | |
72 | + putLong(generator, AUTHOR_ID, rs, index++); | |
73 | + putString(generator, AUTHOR_LOGIN_ID, rs, index++); | |
74 | + putString(generator, AUTHOR_NAME, rs, index++); | |
75 | + putClob(generator, CONTENTS, rs, index++); | |
76 | + } | |
77 | + | |
78 | + @Override | |
79 | + public String getTable() { | |
80 | + return "COMMIT_COMMENT"; | |
81 | + } | |
82 | + | |
83 | + @Override | |
84 | + protected String getInsertSql() { | |
85 | + return "INSERT INTO COMMIT_COMMENT " + | |
86 | + "(ID, PROJECT_ID, COMMIT_ID, PATH, LINE, SIDE, CREATED_DATE, " + | |
87 | + "AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, CONTENTS) " + values(11); | |
88 | + } | |
89 | + | |
90 | + @Override | |
91 | + protected String getSelectSql() { | |
92 | + return "SELECT ID, PROJECT_ID, COMMIT_ID, PATH, LINE, SIDE, CREATED_DATE, " + | |
93 | + "AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, CONTENTS FROM COMMIT_COMMENT"; | |
94 | + } | |
95 | +} |
+++ app/data/exchangers/EmailDataExchanger.java
... | ... | @@ -0,0 +1,74 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class EmailDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; //BIGINT nullable? 0 | |
35 | + private static final String USER_ID = "user_id"; //BIGINT nullable? 1 | |
36 | + private static final String EMAIL = "email"; //VARCHAR nullable? 1 | |
37 | + private static final String TOKEN = "token"; //VARCHAR nullable? 1 | |
38 | + private static final String VALID = "valid"; //BOOLEAN nullable? 1 | |
39 | + | |
40 | + @Override | |
41 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
42 | + short index = 1; | |
43 | + ps.setLong(index++, node.get(ID).longValue()); //BIGINT nullable? 0 | |
44 | + ps.setLong(index++, node.get(USER_ID).longValue()); //BIGINT nullable? 1 | |
45 | + ps.setString(index++, node.get(EMAIL).textValue()); //VARCHAR nullable? 1 | |
46 | + ps.setString(index++, node.get(TOKEN).textValue()); //VARCHAR nullable? 1 | |
47 | + ps.setBoolean(index++, node.get(VALID).booleanValue()); //BOOLEAN nullable? 1 | |
48 | + } | |
49 | + | |
50 | + @Override | |
51 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
52 | + short index = 1; | |
53 | + putLong(generator, ID, rs, index++); | |
54 | + putLong(generator, USER_ID, rs, index++); | |
55 | + putString(generator, EMAIL, rs, index++); | |
56 | + putString(generator, TOKEN, rs, index++); | |
57 | + putBoolean(generator, VALID, rs, index++); | |
58 | + } | |
59 | + | |
60 | + @Override | |
61 | + public String getTable() { | |
62 | + return "EMAIL"; | |
63 | + } | |
64 | + | |
65 | + @Override | |
66 | + protected String getInsertSql() { | |
67 | + return "INSERT INTO EMAIL (ID, USER_ID, EMAIL, TOKEN, VALID)" + values(5); | |
68 | + } | |
69 | + | |
70 | + @Override | |
71 | + protected String getSelectSql() { | |
72 | + return "select ID, USER_ID, EMAIL, TOKEN, VALID from EMAIL"; | |
73 | + } | |
74 | +} |
+++ app/data/exchangers/IssueCommentDataExchanger.java
... | ... | @@ -0,0 +1,84 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueCommentDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String CREATED_DATE = "created_date"; | |
37 | + private static final String AUTHOR_ID = "author_id"; | |
38 | + private static final String AUTHOR_LOGIN_ID = "author_login_id"; | |
39 | + private static final String AUTHOR_NAME = "author_name"; | |
40 | + private static final String ISSUE_ID = "issue_id"; | |
41 | + private static final String CONTENTS = "contents"; | |
42 | + | |
43 | + @Override | |
44 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
45 | + short index = 1; | |
46 | + ps.setLong(index++, node.get(ID).longValue()); | |
47 | + ps.setTimestamp(index++, timestamp(node.get(CREATED_DATE).longValue())); | |
48 | + ps.setLong(index++, node.get(AUTHOR_ID).longValue()); | |
49 | + ps.setString(index++, node.get(AUTHOR_LOGIN_ID).textValue()); | |
50 | + ps.setString(index++, node.get(AUTHOR_NAME).textValue()); | |
51 | + ps.setLong(index++, node.get(ISSUE_ID).longValue()); | |
52 | + setClob(ps, index++, node, CONTENTS); | |
53 | + } | |
54 | + | |
55 | + @Override | |
56 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
57 | + short index = 1; | |
58 | + putLong(generator, ID, rs, index++); | |
59 | + putTimestamp(generator, CREATED_DATE, rs, index++); | |
60 | + putLong(generator, AUTHOR_ID, rs, index++); | |
61 | + putString(generator, AUTHOR_LOGIN_ID, rs, index++); | |
62 | + putString(generator, AUTHOR_NAME, rs, index++); | |
63 | + putLong(generator, ISSUE_ID, rs, index++); | |
64 | + putClob(generator, CONTENTS, rs, index++); | |
65 | + | |
66 | + } | |
67 | + | |
68 | + @Override | |
69 | + public String getTable() { | |
70 | + return "ISSUE_COMMENT"; | |
71 | + } | |
72 | + | |
73 | + @Override | |
74 | + protected String getInsertSql() { | |
75 | + return "INSERT INTO ISSUE_COMMENT (ID, CREATED_DATE, AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, " + | |
76 | + "ISSUE_ID, CONTENTS) " + values(7); | |
77 | + } | |
78 | + | |
79 | + @Override | |
80 | + protected String getSelectSql() { | |
81 | + return "SELECT ID, CREATED_DATE, AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, ISSUE_ID, CONTENTS " + | |
82 | + "FROM ISSUE_COMMENT"; | |
83 | + } | |
84 | +} |
+++ app/data/exchangers/IssueCommentVoterDataExchanger.java
... | ... | @@ -0,0 +1,71 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueCommentVoterDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ISSUE_COMMENT_ID = "issue_comment_id"; | |
36 | + private static final String USER_ID = "user_id"; | |
37 | + | |
38 | + @Override | |
39 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
40 | + short index = 1; | |
41 | + ps.setLong(index++, node.get(ISSUE_COMMENT_ID).longValue()); | |
42 | + ps.setLong(index++, node.get(USER_ID).longValue()); | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
47 | + short index = 1; | |
48 | + putLong(generator, ISSUE_COMMENT_ID, rs, index++); | |
49 | + putLong(generator, USER_ID, rs, index++); | |
50 | + } | |
51 | + | |
52 | + @Override | |
53 | + public String getTable() { | |
54 | + return "ISSUE_COMMENT_VOTER"; | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + protected String getInsertSql() { | |
59 | + return "INSERT INTO ISSUE_COMMENT_VOTER (ISSUE_COMMENT_ID, USER_ID) " + values(2); | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + protected String getSelectSql() { | |
64 | + return "SELECT ISSUE_COMMENT_ID, USER_ID FROM ISSUE_COMMENT_VOTER"; | |
65 | + } | |
66 | + | |
67 | + @Override | |
68 | + protected boolean hasSequence() { | |
69 | + return false; | |
70 | + } | |
71 | +} |
+++ app/data/exchangers/IssueDataExchanger.java
... | ... | @@ -0,0 +1,108 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String TITLE = "title"; | |
37 | + private static final String BODY = "body"; | |
38 | + private static final String CREATED_DATE = "created_date"; | |
39 | + private static final String NUM_OF_COMMENTS = "num_of_comments"; | |
40 | + private static final String MILESTONE_ID = "milestone_id"; | |
41 | + private static final String AUTHOR_ID = "author_id"; | |
42 | + private static final String AUTHOR_LOGIN_ID = "author_login_id"; | |
43 | + private static final String AUTHOR_NAME = "author_name"; | |
44 | + private static final String STATE = "state"; | |
45 | + private static final String PROJECT_ID = "project_id"; | |
46 | + private static final String ASSIGNEE_ID = "assignee_id"; | |
47 | + private static final String NUMBER = "number"; | |
48 | + private static final String UPDATED_DATE = "updated_date"; | |
49 | + private static final String DUE_DATE = "due_date"; | |
50 | + | |
51 | + @Override | |
52 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
53 | + short index = 1; | |
54 | + ps.setLong(index++, node.get(ID).longValue()); | |
55 | + ps.setString(index++, node.get(TITLE).textValue()); | |
56 | + setClob(ps, index++, node, BODY); | |
57 | + ps.setTimestamp(index++, timestamp(node.get(CREATED_DATE).longValue())); | |
58 | + ps.setInt(index++, node.get(NUM_OF_COMMENTS).intValue()); | |
59 | + setNullableLong(ps, index++, node, MILESTONE_ID); | |
60 | + ps.setLong(index++, node.get(AUTHOR_ID).longValue()); | |
61 | + ps.setString(index++, node.get(AUTHOR_LOGIN_ID).textValue()); | |
62 | + ps.setString(index++, node.get(AUTHOR_NAME).textValue()); | |
63 | + ps.setInt(index++, node.get(STATE).intValue()); | |
64 | + ps.setLong(index++, node.get(PROJECT_ID).longValue()); | |
65 | + setNullableLong(ps, index++, node, ASSIGNEE_ID); | |
66 | + ps.setLong(index++, node.get(NUMBER).longValue()); | |
67 | + ps.setTimestamp(index++, timestamp(node.get(UPDATED_DATE).longValue())); | |
68 | + ps.setTimestamp(index++, timestamp(node.get(DUE_DATE).longValue())); | |
69 | + } | |
70 | + | |
71 | + @Override | |
72 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
73 | + short index = 1; | |
74 | + putLong(generator, ID, rs, index++); | |
75 | + putString(generator, TITLE, rs, index++); | |
76 | + putClob(generator, BODY, rs, index++); | |
77 | + putTimestamp(generator, CREATED_DATE, rs, index++); | |
78 | + putInt(generator, NUM_OF_COMMENTS, rs, index++); | |
79 | + putLong(generator, MILESTONE_ID, rs, index++); | |
80 | + putLong(generator, AUTHOR_ID, rs, index++); | |
81 | + putString(generator, AUTHOR_LOGIN_ID, rs, index++); | |
82 | + putString(generator, AUTHOR_NAME, rs, index++); | |
83 | + putInt(generator, STATE, rs, index++); | |
84 | + putLong(generator, PROJECT_ID, rs, index++); | |
85 | + putLong(generator, ASSIGNEE_ID, rs, index++); | |
86 | + putLong(generator, NUMBER, rs, index++); | |
87 | + putTimestamp(generator, UPDATED_DATE, rs, index++); | |
88 | + putTimestamp(generator, DUE_DATE, rs, index++); | |
89 | + } | |
90 | + | |
91 | + @Override | |
92 | + public String getTable() { | |
93 | + return "ISSUE"; | |
94 | + } | |
95 | + | |
96 | + @Override | |
97 | + protected String getInsertSql() { | |
98 | + return "INSERT INTO ISSUE (ID, TITLE, BODY, CREATED_DATE, NUM_OF_COMMENTS, MILESTONE_ID, AUTHOR_ID, " + | |
99 | + "AUTHOR_LOGIN_ID, AUTHOR_NAME, STATE, PROJECT_ID, ASSIGNEE_ID, NUMBER, UPDATED_DATE, DUE_DATE) " + | |
100 | + values(15); | |
101 | + } | |
102 | + | |
103 | + @Override | |
104 | + protected String getSelectSql() { | |
105 | + return "SELECT ID, TITLE, BODY, CREATED_DATE, NUM_OF_COMMENTS, MILESTONE_ID, AUTHOR_ID, AUTHOR_LOGIN_ID, " + | |
106 | + "AUTHOR_NAME, STATE, PROJECT_ID, ASSIGNEE_ID, NUMBER, UPDATED_DATE, DUE_DATE FROM ISSUE"; | |
107 | + } | |
108 | +} |
+++ app/data/exchangers/IssueEventDataExchanger.java
... | ... | @@ -0,0 +1,86 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class IssueEventDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; | |
35 | + private static final String CREATED = "created"; | |
36 | + private static final String SENDER_LOGIN_ID = "sender_login_id"; | |
37 | + private static final String ISSUE_ID = "issue_id"; | |
38 | + private static final String EVENT_TYPE = "event_type"; | |
39 | + private static final String OLD_VALUE = "old_value"; | |
40 | + private static final String NEW_VALUE = "new_value"; | |
41 | + private static final String SENDER_EMAIL = "sender_email"; | |
42 | + | |
43 | + @Override | |
44 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
45 | + short index = 1; | |
46 | + ps.setLong(index++, node.get(ID).longValue()); | |
47 | + ps.setTimestamp(index++, timestamp(node.get(CREATED).longValue())); | |
48 | + ps.setString(index++, node.get(SENDER_LOGIN_ID).textValue()); | |
49 | + setNullableLong(ps, index++, node, ISSUE_ID); | |
50 | + ps.setString(index++, node.get(EVENT_TYPE).textValue()); | |
51 | + setClob(ps, index++, node, OLD_VALUE); | |
52 | + setClob(ps, index++, node, NEW_VALUE); | |
53 | + ps.setString(index++, node.get(SENDER_EMAIL).textValue()); | |
54 | + } | |
55 | + | |
56 | + @Override | |
57 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
58 | + short index = 1; | |
59 | + putLong(generator, ID, rs, index++); | |
60 | + putTimestamp(generator, CREATED, rs, index++); | |
61 | + putString(generator, SENDER_LOGIN_ID, rs, index++); | |
62 | + putLong(generator, ISSUE_ID, rs, index++); | |
63 | + putString(generator, EVENT_TYPE, rs, index++); | |
64 | + putClob(generator, OLD_VALUE, rs, index++); | |
65 | + putClob(generator, NEW_VALUE, rs, index++); | |
66 | + putString(generator, SENDER_EMAIL, rs, index++); | |
67 | + } | |
68 | + | |
69 | + @Override | |
70 | + public String getTable() { | |
71 | + return "ISSUE_EVENT"; | |
72 | + } | |
73 | + | |
74 | + @Override | |
75 | + protected String getInsertSql() { | |
76 | + return "INSERT INTO ISSUE_EVENT " + | |
77 | + "(ID, CREATED, SENDER_LOGIN_ID, ISSUE_ID, EVENT_TYPE, OLD_VALUE, NEW_VALUE, SENDER_EMAIL) " + | |
78 | + values(8); | |
79 | + } | |
80 | + | |
81 | + @Override | |
82 | + protected String getSelectSql() { | |
83 | + return "SELECT ID, CREATED, SENDER_LOGIN_ID, ISSUE_ID, EVENT_TYPE, OLD_VALUE, " + | |
84 | + "NEW_VALUE, SENDER_EMAIL FROM ISSUE_EVENT"; | |
85 | + } | |
86 | +} |
+++ app/data/exchangers/IssueIssueLabelDataExchanger.java
... | ... | @@ -0,0 +1,71 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueIssueLabelDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ISSUE_ID = "issue_id"; // BIGINT(19) NOT NULL | |
36 | + private static final String ISSUE_LABEL_ID = "issue_label_id"; // BIGINT(19) NOT NULL | |
37 | + | |
38 | + @Override | |
39 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
40 | + short index = 1; | |
41 | + ps.setLong(index++, node.get(ISSUE_ID).longValue()); | |
42 | + ps.setLong(index++, node.get(ISSUE_LABEL_ID).longValue()); | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
47 | + short index = 1; | |
48 | + putLong(generator, ISSUE_ID, rs, index++); | |
49 | + putLong(generator, ISSUE_LABEL_ID, rs, index++); | |
50 | + } | |
51 | + | |
52 | + @Override | |
53 | + public String getTable() { | |
54 | + return "ISSUE_ISSUE_LABEL"; | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + protected String getInsertSql() { | |
59 | + return "INSERT INTO ISSUE_ISSUE_LABEL (ISSUE_ID, ISSUE_LABEL_ID) " + values(2); | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + protected String getSelectSql() { | |
64 | + return "SELECT ISSUE_ID, ISSUE_LABEL_ID FROM ISSUE_ISSUE_LABEL"; | |
65 | + } | |
66 | + | |
67 | + @Override | |
68 | + protected boolean hasSequence() { | |
69 | + return false; | |
70 | + } | |
71 | +} |
+++ app/data/exchangers/IssueLabelCategoryDataExchanger.java
... | ... | @@ -0,0 +1,72 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueLabelCategoryDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String PROJECT_ID = "project_id"; | |
37 | + private static final String NAME = "name"; | |
38 | + private static final String IS_EXCLUSIVE = "is_exclusive"; | |
39 | + | |
40 | + @Override | |
41 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
42 | + short index = 1; | |
43 | + ps.setLong(index++, node.get(ID).longValue()); | |
44 | + ps.setLong(index++, node.get(PROJECT_ID).longValue()); | |
45 | + ps.setString(index++, node.get(NAME).textValue()); | |
46 | + ps.setBoolean(index++, node.get(IS_EXCLUSIVE).booleanValue()); | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
51 | + short index = 1; | |
52 | + putLong(generator, ID, rs, index++); | |
53 | + putLong(generator, PROJECT_ID, rs, index++); | |
54 | + putString(generator, NAME, rs, index++); | |
55 | + putBoolean(generator, IS_EXCLUSIVE, rs, index++); | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + public String getTable() { | |
60 | + return "ISSUE_LABEL_CATEGORY"; | |
61 | + } | |
62 | + | |
63 | + @Override | |
64 | + protected String getInsertSql() { | |
65 | + return "INSERT INTO ISSUE_LABEL_CATEGORY (ID, PROJECT_ID, NAME, IS_EXCLUSIVE) " + values(4); | |
66 | + } | |
67 | + | |
68 | + @Override | |
69 | + protected String getSelectSql() { | |
70 | + return "SELECT ID, PROJECT_ID, NAME, IS_EXCLUSIVE FROM ISSUE_LABEL_CATEGORY"; | |
71 | + } | |
72 | +} |
+++ app/data/exchangers/IssueLabelDataExchanger.java
... | ... | @@ -0,0 +1,75 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueLabelDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; // BIGINT(19) NOT NULL | |
36 | + private static final String COLOR = "color"; // VARCHAR(255) | |
37 | + private static final String NAME = "name"; // VARCHAR(255) | |
38 | + private static final String PROJECT_ID = "project_id"; // BIGINT(19) | |
39 | + private static final String CATEGORY_ID = "category_id"; // BIGINT(19) NOT NULL | |
40 | + | |
41 | + @Override | |
42 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
43 | + short index = 1; | |
44 | + ps.setLong(index++, node.get(ID).longValue()); | |
45 | + ps.setString(index++, node.get(COLOR).textValue()); | |
46 | + ps.setString(index++, node.get(NAME).textValue()); | |
47 | + setNullableLong(ps, index++, node, PROJECT_ID); | |
48 | + ps.setLong(index++, node.get(CATEGORY_ID).longValue()); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
53 | + short index = 1; | |
54 | + putLong(generator, ID, rs, index++); | |
55 | + putString(generator, COLOR, rs, index++); | |
56 | + putString(generator, NAME, rs, index++); | |
57 | + putLong(generator, PROJECT_ID, rs, index++); | |
58 | + putLong(generator, CATEGORY_ID, rs, index++); | |
59 | + } | |
60 | + | |
61 | + @Override | |
62 | + public String getTable() { | |
63 | + return "ISSUE_LABEL"; | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + protected String getInsertSql() { | |
68 | + return "INSERT INTO ISSUE_LABEL (ID, COLOR, NAME, PROJECT_ID, CATEGORY_ID) " + values(5); | |
69 | + } | |
70 | + | |
71 | + @Override | |
72 | + protected String getSelectSql() { | |
73 | + return "SELECT ID, COLOR, NAME, PROJECT_ID, CATEGORY_ID FROM ISSUE_LABEL"; | |
74 | + } | |
75 | +} |
+++ app/data/exchangers/IssueVoterDataExchanger.java
... | ... | @@ -0,0 +1,71 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class IssueVoterDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ISSUE_ID = "issue_id"; // BIGINT(19) NOT NULL | |
36 | + private static final String USER_ID = "user_id"; // BIGINT(19) NOT NULL | |
37 | + | |
38 | + @Override | |
39 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
40 | + short index = 1; | |
41 | + ps.setLong(index++, node.get(ISSUE_ID).longValue()); | |
42 | + ps.setLong(index++, node.get(USER_ID).longValue()); | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
47 | + short index = 1; | |
48 | + putLong(generator, ISSUE_ID, rs, index++); | |
49 | + putLong(generator, USER_ID, rs, index++); | |
50 | + } | |
51 | + | |
52 | + @Override | |
53 | + public String getTable() { | |
54 | + return "ISSUE_VOTER"; | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + protected String getInsertSql() { | |
59 | + return "INSERT INTO ISSUE_VOTER (ISSUE_ID, USER_ID) " + values(2); | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + protected String getSelectSql() { | |
64 | + return "SELECT ISSUE_ID, USER_ID FROM ISSUE_VOTER"; | |
65 | + } | |
66 | + | |
67 | + @Override | |
68 | + protected boolean hasSequence() { | |
69 | + return false; | |
70 | + } | |
71 | +} |
+++ app/data/exchangers/LabelDataExchanger.java
... | ... | @@ -0,0 +1,69 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class LabelDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String NAME = "name"; | |
37 | + private static final String CATEGORY = "category"; | |
38 | + | |
39 | + @Override | |
40 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
41 | + short index = 1; | |
42 | + ps.setLong(index++, node.get(ID).longValue()); | |
43 | + ps.setString(index++, node.get(NAME).textValue()); | |
44 | + ps.setString(index++, node.get(CATEGORY).textValue()); | |
45 | + } | |
46 | + | |
47 | + @Override | |
48 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
49 | + short index = 1; | |
50 | + putLong(generator, ID, rs, index++); | |
51 | + putString(generator, NAME, rs, index++); | |
52 | + putString(generator, CATEGORY, rs, index++); | |
53 | + } | |
54 | + | |
55 | + @Override | |
56 | + public String getTable() { | |
57 | + return "LABEL"; | |
58 | + } | |
59 | + | |
60 | + @Override | |
61 | + protected String getInsertSql() { | |
62 | + return "INSERT INTO LABEL (ID, NAME, CATEGORY) " + values(3); | |
63 | + } | |
64 | + | |
65 | + @Override | |
66 | + protected String getSelectSql() { | |
67 | + return "SELECT ID, NAME, CATEGORY FROM LABEL"; | |
68 | + } | |
69 | +} |
+++ app/data/exchangers/MentionDataExchanger.java
... | ... | @@ -0,0 +1,71 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class MentionDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; | |
35 | + private static final String RESOURCE_TYPE = "resource_type"; | |
36 | + private static final String RESOURCE_ID = "resource_id"; | |
37 | + private static final String USER_ID = "user_id"; | |
38 | + | |
39 | + @Override | |
40 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
41 | + short index = 1; | |
42 | + ps.setLong(index++, node.get(ID).longValue()); | |
43 | + ps.setString(index++, node.get(RESOURCE_TYPE).textValue()); | |
44 | + ps.setString(index++, node.get(RESOURCE_ID).textValue()); | |
45 | + setNullableLong(ps, index++, node, USER_ID); | |
46 | + } | |
47 | + | |
48 | + @Override | |
49 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
50 | + short index = 1; | |
51 | + putLong(generator, ID, rs, index++); | |
52 | + putString(generator, RESOURCE_TYPE, rs, index++); | |
53 | + putString(generator, RESOURCE_ID, rs, index++); | |
54 | + putLong(generator, USER_ID, rs, index++); | |
55 | + } | |
56 | + | |
57 | + @Override | |
58 | + public String getTable() { | |
59 | + return "MENTION"; | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + protected String getInsertSql() { | |
64 | + return "INSERT INTO MENTION (ID, RESOURCE_TYPE, RESOURCE_ID, USER_ID) " + values(4); | |
65 | + } | |
66 | + | |
67 | + @Override | |
68 | + protected String getSelectSql() { | |
69 | + return "SELECT ID, RESOURCE_TYPE, RESOURCE_ID, USER_ID FROM MENTION"; | |
70 | + } | |
71 | +} |
+++ app/data/exchangers/MilestoneDataExchanger.java
... | ... | @@ -0,0 +1,79 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class MilestoneDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; // BIGINT(19) NOT NULL | |
36 | + private static final String TITLE = "title"; // VARCHAR(255) | |
37 | + private static final String DUE_DATE = "due_date"; // TIMESTAMP(23, 10) | |
38 | + private static final String CONTENTS = "contents"; // CLOB(2147483647) | |
39 | + private static final String STATE = "state"; // INTEGER(10) | |
40 | + private static final String PROJECT_ID = "project_id"; // BIGINT(19) | |
41 | + | |
42 | + @Override | |
43 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
44 | + short index = 1; | |
45 | + ps.setLong(index++, node.get(ID).longValue()); | |
46 | + ps.setString(index++, node.get(TITLE).textValue()); | |
47 | + ps.setTimestamp(index++, timestamp(node.get(DUE_DATE).longValue())); | |
48 | + setClob(ps, index++, node, CONTENTS); | |
49 | + ps.setInt(index++, node.get(STATE).intValue()); | |
50 | + setNullableLong(ps, index++, node, PROJECT_ID); | |
51 | + } | |
52 | + | |
53 | + @Override | |
54 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
55 | + short index = 1; | |
56 | + putLong(generator, ID, rs, index++); | |
57 | + putString(generator, TITLE, rs, index++); | |
58 | + putTimestamp(generator, DUE_DATE, rs, index++); | |
59 | + putClob(generator, CONTENTS, rs, index++); | |
60 | + putInt(generator, STATE, rs, index++); | |
61 | + putLong(generator, PROJECT_ID, rs, index++); | |
62 | + } | |
63 | + | |
64 | + @Override | |
65 | + public String getTable() { | |
66 | + return "MILESTONE"; | |
67 | + } | |
68 | + | |
69 | + @Override | |
70 | + protected String getInsertSql() { | |
71 | + return "INSERT INTO MILESTONE (ID, TITLE, DUE_DATE, CONTENTS, STATE, PROJECT_ID) " + | |
72 | + values(6); | |
73 | + } | |
74 | + | |
75 | + @Override | |
76 | + protected String getSelectSql() { | |
77 | + return "SELECT ID, TITLE, DUE_DATE, CONTENTS, STATE, PROJECT_ID FROM MILESTONE"; | |
78 | + } | |
79 | +} |
+++ app/data/exchangers/NotificationEventDataExchanger.java
... | ... | @@ -0,0 +1,90 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class NotificationEventDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; | |
35 | + private static final String TITLE = "title"; | |
36 | + private static final String SENDER_ID = "sender_id"; | |
37 | + private static final String CREATED = "created"; | |
38 | + private static final String RESOURCE_TYPE = "resource_type"; | |
39 | + private static final String RESOURCE_ID = "resource_id"; | |
40 | + private static final String EVENT_TYPE = "event_type"; | |
41 | + private static final String OLD_VALUE = "old_value"; | |
42 | + private static final String NEW_VALUE = "new_value"; | |
43 | + | |
44 | + @Override | |
45 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
46 | + short index = 1; | |
47 | + ps.setLong(index++, node.get(ID).longValue()); | |
48 | + ps.setString(index++, node.get(TITLE).textValue()); | |
49 | + setNullableLong(ps, index++, node, SENDER_ID); | |
50 | + ps.setTimestamp(index++, timestamp(node.get(CREATED).longValue())); | |
51 | + ps.setString(index++, node.get(RESOURCE_TYPE).textValue()); | |
52 | + ps.setString(index++, node.get(RESOURCE_ID).textValue()); | |
53 | + ps.setString(index++, node.get(EVENT_TYPE).textValue()); | |
54 | + setClob(ps, index++, node, OLD_VALUE); | |
55 | + setClob(ps, index++, node, NEW_VALUE); | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
60 | + short index = 1; | |
61 | + putLong(generator, ID, rs, index++); | |
62 | + putString(generator, TITLE, rs, index++); | |
63 | + putLong(generator, SENDER_ID, rs, index++); | |
64 | + putTimestamp(generator, CREATED, rs, index++); | |
65 | + putString(generator, RESOURCE_TYPE, rs, index++); | |
66 | + putString(generator, RESOURCE_ID, rs, index++); | |
67 | + putString(generator, EVENT_TYPE, rs, index++); | |
68 | + putClob(generator, OLD_VALUE, rs, index++); | |
69 | + putClob(generator, NEW_VALUE, rs, index++); | |
70 | + } | |
71 | + | |
72 | + @Override | |
73 | + public String getTable() { | |
74 | + return "NOTIFICATION_EVENT"; | |
75 | + } | |
76 | + | |
77 | + @Override | |
78 | + protected String getInsertSql() { | |
79 | + return "INSERT INTO NOTIFICATION_EVENT " + | |
80 | + "(ID, TITLE, SENDER_ID, CREATED, RESOURCE_TYPE, " + | |
81 | + "RESOURCE_ID, EVENT_TYPE, OLD_VALUE, NEW_VALUE) " + values(9); | |
82 | + } | |
83 | + | |
84 | + @Override | |
85 | + protected String getSelectSql() { | |
86 | + return "SELECT ID, TITLE, SENDER_ID, CREATED, RESOURCE_TYPE, " + | |
87 | + "RESOURCE_ID, EVENT_TYPE, OLD_VALUE, NEW_VALUE " + | |
88 | + "FROM NOTIFICATION_EVENT"; | |
89 | + } | |
90 | +} |
+++ app/data/exchangers/NotificationEventUserDataExchanger.java
... | ... | @@ -0,0 +1,70 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class NotificationEventUserDataExchanger extends DefaultExchanger { | |
34 | + private static final String NOTIFICATION_EVENT_ID = "notification_event_id"; | |
35 | + private static final String N4USER_ID = "n4user_id"; | |
36 | + | |
37 | + @Override | |
38 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
39 | + short index = 1; | |
40 | + ps.setLong(index++, node.get(NOTIFICATION_EVENT_ID).longValue()); | |
41 | + ps.setLong(index++, node.get(N4USER_ID).longValue()); | |
42 | + } | |
43 | + | |
44 | + @Override | |
45 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
46 | + short index = 1; | |
47 | + putLong(generator, NOTIFICATION_EVENT_ID, rs, index++); | |
48 | + putLong(generator, N4USER_ID, rs, index++); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public String getTable() { | |
53 | + return "NOTIFICATION_EVENT_N4USER"; | |
54 | + } | |
55 | + | |
56 | + @Override | |
57 | + protected String getInsertSql() { | |
58 | + return "INSERT INTO NOTIFICATION_EVENT_N4USER (NOTIFICATION_EVENT_ID, N4USER_ID) " + values(2); | |
59 | + } | |
60 | + | |
61 | + @Override | |
62 | + protected String getSelectSql() { | |
63 | + return "SELECT NOTIFICATION_EVENT_ID, N4USER_ID FROM NOTIFICATION_EVENT_N4USER"; | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + protected boolean hasSequence() { | |
68 | + return false; | |
69 | + } | |
70 | +} |
+++ app/data/exchangers/NotificationMailDataExchanger.java
... | ... | @@ -0,0 +1,65 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class NotificationMailDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; | |
35 | + private static final String NOTIFICATION_EVENT_ID = "notification_event_id"; | |
36 | + | |
37 | + @Override | |
38 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
39 | + short index = 1; | |
40 | + ps.setLong(index++, node.get(ID).longValue()); | |
41 | + setNullableLong(ps, index++, node, NOTIFICATION_EVENT_ID); | |
42 | + } | |
43 | + | |
44 | + @Override | |
45 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
46 | + short index = 1; | |
47 | + putLong(generator, ID, rs, index++); | |
48 | + putLong(generator, NOTIFICATION_EVENT_ID, rs, index++); | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public String getTable() { | |
53 | + return "NOTIFICATION_MAIL"; | |
54 | + } | |
55 | + | |
56 | + @Override | |
57 | + protected String getInsertSql() { | |
58 | + return "INSERT INTO NOTIFICATION_MAIL (ID, NOTIFICATION_EVENT_ID) " + values(2); | |
59 | + } | |
60 | + | |
61 | + @Override | |
62 | + protected String getSelectSql() { | |
63 | + return "SELECT ID, NOTIFICATION_EVENT_ID FROM NOTIFICATION_MAIL"; | |
64 | + } | |
65 | +} |
+++ app/data/exchangers/OrganizationDataExchanger.java
... | ... | @@ -0,0 +1,72 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class OrganizationDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String NAME = "name"; | |
37 | + private static final String DESCR = "descr"; | |
38 | + private static final String CREATED = "created"; | |
39 | + | |
40 | + @Override | |
41 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
42 | + short index = 1; | |
43 | + ps.setLong(index++, node.get(ID).longValue()); | |
44 | + ps.setString(index++, node.get(NAME).textValue()); | |
45 | + ps.setString(index++, node.get(DESCR).textValue()); | |
46 | + ps.setTimestamp(index++, timestamp(node.get(CREATED).longValue())); | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
51 | + short index = 1; | |
52 | + putLong(generator, ID, rs, index++); | |
53 | + putString(generator, NAME, rs, index++); | |
54 | + putString(generator, DESCR, rs, index++); | |
55 | + putTimestamp(generator, CREATED, rs, index++); | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + public String getTable() { | |
60 | + return "ORGANIZATION"; | |
61 | + } | |
62 | + | |
63 | + @Override | |
64 | + protected String getInsertSql() { | |
65 | + return "INSERT INTO ORGANIZATION (ID, NAME, DESCR, CREATED) " + values(4); | |
66 | + } | |
67 | + | |
68 | + @Override | |
69 | + protected String getSelectSql() { | |
70 | + return "SELECT ID, NAME, DESCR, CREATED FROM ORGANIZATION"; | |
71 | + } | |
72 | +} |
+++ app/data/exchangers/OrganizationUserDataExchanger.java
... | ... | @@ -0,0 +1,72 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Keeun Baik | |
32 | + */ | |
33 | +public class OrganizationUserDataExchanger extends DefaultExchanger { | |
34 | + | |
35 | + private static final String ID = "id"; | |
36 | + private static final String USER_ID = "user_id"; | |
37 | + private static final String ORGANIZATION_ID = "organization_id"; | |
38 | + private static final String ROLE_ID = "role_id"; | |
39 | + | |
40 | + @Override | |
41 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
42 | + short index = 1; | |
43 | + ps.setLong(index++, node.get(ID).longValue()); | |
44 | + ps.setLong(index++, node.get(USER_ID).longValue()); | |
45 | + ps.setLong(index++, node.get(ORGANIZATION_ID).longValue()); | |
46 | + ps.setLong(index++, node.get(ROLE_ID).longValue()); | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
51 | + short index = 1; | |
52 | + putLong(generator, ID, rs, index++); | |
53 | + putLong(generator, USER_ID, rs, index++); | |
54 | + putLong(generator, ORGANIZATION_ID, rs, index++); | |
55 | + putLong(generator, ROLE_ID, rs, index++); | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + public String getTable() { | |
60 | + return "ORGANIZATION_USER"; | |
61 | + } | |
62 | + | |
63 | + @Override | |
64 | + protected String getInsertSql() { | |
65 | + return "INSERT INTO ORGANIZATION_USER (ID, USER_ID, ORGANIZATION_ID, ROLE_ID) " + values(4); | |
66 | + } | |
67 | + | |
68 | + @Override | |
69 | + protected String getSelectSql() { | |
70 | + return "SELECT ID, USER_ID, ORGANIZATION_ID, ROLE_ID FROM ORGANIZATION_USER"; | |
71 | + } | |
72 | +} |
+++ app/data/exchangers/OriginalEmailDataExchanger.java
... | ... | @@ -0,0 +1,75 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Yi EungJun | |
32 | + */ | |
33 | +public class OriginalEmailDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; | |
35 | + private static final String MESSAGE_ID = "message_id"; | |
36 | + private static final String RESOURCE_TYPE = "resource_type"; | |
37 | + private static final String RESOURCE_ID = "resource_id"; | |
38 | + private static final String HANDLED_DATE = "handled_date"; | |
39 | + | |
40 | + @Override | |
41 | + public String getTable() { | |
42 | + return "ORIGINAL_EMAIL"; | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
47 | + short index = 1; | |
48 | + ps.setLong(index++, node.get(ID).longValue()); | |
49 | + ps.setString(index++, node.get(MESSAGE_ID).textValue()); | |
50 | + ps.setString(index++, node.get(RESOURCE_TYPE).textValue()); | |
51 | + ps.setString(index++, node.get(RESOURCE_ID).textValue()); | |
52 | + ps.setTimestamp(index++, timestamp(node.get(HANDLED_DATE).longValue())); | |
53 | + } | |
54 | + | |
55 | + @Override | |
56 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
57 | + short index = 1; | |
58 | + putLong(generator, ID, rs, index++); | |
59 | + putString(generator, MESSAGE_ID, rs, index++); | |
60 | + putString(generator, RESOURCE_TYPE, rs, index++); | |
61 | + putString(generator, RESOURCE_ID, rs, index++); | |
62 | + putTimestamp(generator, HANDLED_DATE, rs, index++); | |
63 | + } | |
64 | + | |
65 | + @Override | |
66 | + protected String getInsertSql() { | |
67 | + return "INSERT INTO ORIGINAL_EMAIL " + | |
68 | + "(ID, MESSAGE_ID, RESOURCE_TYPE, RESOURCE_ID, HANDLED_DATE) " + values(5); | |
69 | + } | |
70 | + | |
71 | + @Override | |
72 | + protected String getSelectSql() { | |
73 | + return "SELECT ID, MESSAGE_ID, RESOURCE_TYPE, RESOURCE_ID, HANDLED_DATE FROM ORIGINAL_EMAIL"; | |
74 | + } | |
75 | +} |
+++ app/data/exchangers/PostingCommentDataExchanger.java
... | ... | @@ -0,0 +1,82 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |
4 | + * Copyright 2015 NAVER Corp. | |
5 | + * http://yobi.io | |
6 | + * | |
7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | + * you may not use this file except in compliance with the License. | |
9 | + * You may obtain a copy of the License at | |
10 | + * | |
11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + * | |
13 | + * Unless required by applicable law or agreed to in writing, software | |
14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | + * See the License for the specific language governing permissions and | |
17 | + * limitations under the License. | |
18 | + */ | |
19 | +package data.exchangers; | |
20 | + | |
21 | +import com.fasterxml.jackson.core.JsonGenerator; | |
22 | +import com.fasterxml.jackson.databind.JsonNode; | |
23 | +import data.DefaultExchanger; | |
24 | + | |
25 | +import java.io.IOException; | |
26 | +import java.sql.PreparedStatement; | |
27 | +import java.sql.ResultSet; | |
28 | +import java.sql.SQLException; | |
29 | + | |
30 | +/** | |
31 | + * @author Suwon Chae | |
32 | + */ | |
33 | +public class PostingCommentDataExchanger extends DefaultExchanger { | |
34 | + private static final String ID = "id"; //BIGINT nullable? 0 | |
35 | + private static final String CREATED_DATE = "created_date"; //TIMESTAMP nullable? 1 | |
36 | + private static final String AUTHOR_ID = "author_id"; //BIGINT nullable? 1 | |
37 | + private static final String AUTHOR_LOGIN_ID = "author_login_id"; //VARCHAR nullable? 1 | |
38 | + private static final String AUTHOR_NAME = "author_name"; //VARCHAR nullable? 1 | |
39 | + private static final String POSTING_ID = "posting_id"; //BIGINT nullable? 1 | |
40 | + private static final String CONTENTS = "contents"; //CLOB nullable? 1 | |
41 | + | |
42 | + @Override | |
43 | + protected void setPreparedStatement(PreparedStatement ps, JsonNode node) throws SQLException { | |
44 | + short index = 1; | |
45 | + ps.setLong(index++, node.get(ID).longValue()); //BIGINT nullable? 0 | |
46 | + ps.setTimestamp(index++, timestamp(node.get(CREATED_DATE).longValue())); //TIMESTAMP nullable? 1 | |
47 | + setNullableLong(ps, index++, node, AUTHOR_ID); //BIGINT nullable? 1 | |
48 | + ps.setString(index++, node.get(AUTHOR_LOGIN_ID).textValue()); //VARCHAR nullable? 1 | |
49 | + ps.setString(index++, node.get(AUTHOR_NAME).textValue()); //VARCHAR nullable? 1 | |
50 | + setNullableLong(ps, index++, node, POSTING_ID); //BIGINT nullable? 1 | |
51 | + setClob(ps, index++, node, CONTENTS); //CLOB nullable? 1 | |
52 | + } | |
53 | + | |
54 | + @Override | |
55 | + protected void setNode(JsonGenerator generator, ResultSet rs) throws IOException, SQLException { | |
56 | + short index = 1; | |
57 | + putLong(generator, ID, rs, index++); | |
58 | + putTimestamp(generator, CREATED_DATE, rs, index++); | |
59 | + putLong(generator, AUTHOR_ID, rs, index++); | |
60 | + putString(generator, AUTHOR_LOGIN_ID, rs, index++); | |
61 | + putString(generator, AUTHOR_NAME, rs, index++); | |
62 | + putLong(generator, POSTING_ID, rs, index++); | |
63 | + putClob(generator, CONTENTS, rs, index++); | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + public String getTable() { | |
68 | + return "POSTING_COMMENT"; | |
69 | + } | |
70 | + | |
71 | + @Override | |
72 | + protected String getInsertSql() { | |
73 | + return "INSERT INTO POSTING_COMMENT (ID, CREATED_DATE, AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, " + | |
74 | + "POSTING_ID, CONTENTS) " + values(7); | |
75 | + } | |
76 | + | |
77 | + @Override | |
78 | + protected String getSelectSql() { | |
79 | + return "SELECT ID, CREATED_DATE, AUTHOR_ID, AUTHOR_LOGIN_ID, AUTHOR_NAME, POSTING_ID, CONTENTS " + | |
80 | + "FROM POSTING_COMMENT"; | |
81 | + } | |
82 | +} |
+++ app/data/exchangers/PostingDataExchanger.java
... | ... | @@ -0,0 +1,100 @@ |
1 | +/** | |
2 | + * Yobi, Project Hosting SW | |
3 | + * | |