|
9 | 9 | import com.mongodb.client.result.DeleteResult;
|
10 | 10 | import lombok.extern.slf4j.Slf4j;
|
11 | 11 | import org.bson.Document;
|
| 12 | +import org.bson.types.ObjectId; |
12 | 13 | import org.lowcoder.domain.application.model.Application;
|
13 | 14 | import org.lowcoder.domain.application.model.ApplicationHistorySnapshot;
|
14 | 15 | import org.lowcoder.domain.application.model.ApplicationHistorySnapshotTS;
|
| 16 | +import org.lowcoder.domain.application.model.ApplicationRecord; |
15 | 17 | import org.lowcoder.domain.bundle.model.Bundle;
|
16 | 18 | import org.lowcoder.domain.datasource.model.Datasource;
|
17 | 19 | import org.lowcoder.domain.datasource.model.DatasourceStructureDO;
|
|
49 | 51 | import java.time.temporal.ChronoUnit;
|
50 | 52 | import java.util.Arrays;
|
51 | 53 | import java.util.List;
|
| 54 | +import java.util.Map; |
52 | 55 | import java.util.Set;
|
53 | 56 |
|
| 57 | +import static org.lowcoder.api.authentication.util.AdvancedMapUtils.documentToMap; |
54 | 58 | import static org.lowcoder.domain.util.QueryDslUtils.fieldName;
|
55 | 59 | import static org.lowcoder.sdk.util.IDUtils.generate;
|
56 | 60 |
|
@@ -422,6 +426,31 @@ public void populateEmailInUserConnections(MongockTemplate mongoTemplate, Common
|
422 | 426 |
|
423 | 427 | }
|
424 | 428 |
|
| 429 | + @ChangeSet(order = "028", id = "published-to-record", author = "Thomas") |
| 430 | + public void publishedToRecord(MongockTemplate mongoTemplate, CommonConfig commonConfig) { |
| 431 | + Query query = new Query(Criteria.where("publishedApplicationDSL").exists(true)); |
| 432 | + |
| 433 | + MongoCursor<Document> cursor = mongoTemplate.getCollection("application").find(query.getQueryObject()).iterator(); |
| 434 | + |
| 435 | + while (cursor.hasNext()) { |
| 436 | + Document document = cursor.next(); |
| 437 | + Document dsl = (Document) document.get("publishedApplicationDSL"); |
| 438 | + ObjectId id = document.getObjectId("_id"); |
| 439 | + String createdBy = document.getString("createdBy"); |
| 440 | + Map<String, Object> dslMap = documentToMap(dsl); |
| 441 | + ApplicationRecord record = ApplicationRecord.builder() |
| 442 | + .applicationId(id.toHexString()) |
| 443 | + .applicationDSL(dslMap) |
| 444 | + .commitMessage("") |
| 445 | + .tag("1.0.0") |
| 446 | + .createdBy(createdBy) |
| 447 | + .modifiedBy(createdBy) |
| 448 | + .createdAt(Instant.now()) |
| 449 | + .updatedAt(Instant.now()) |
| 450 | + .build(); |
| 451 | + mongoTemplate.insert(record); |
| 452 | + } |
| 453 | + } |
425 | 454 |
|
426 | 455 | private void addGidField(MongockTemplate mongoTemplate, String collectionName) {
|
427 | 456 | // Create a query to match all documents
|
|
0 commit comments