Skip to content

Commit

Permalink
#923: Add title, description, category to the application list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonpoo authored and ludomikula committed Dec 16, 2024
1 parent e8dba1e commit 730d794
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,44 @@ public Map<String, Object> getEditingApplicationDSL() {
}

public String getCategory() {
if(editingApplicationDSL == null || editingApplicationDSL.get("settings") == null) return "";
Object settingsObject = editingApplicationDSL.get("settings");
var liveDSL = getLiveApplicationDsl();
if(liveDSL == null || liveDSL.get("settings") == null) return "";
Object settingsObject = liveDSL.get("settings");
if (settingsObject instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> settings = (Map<String, Object>) editingApplicationDSL.get("settings");
Map<String, Object> settings = (Map<String, Object>) liveDSL.get("settings");
return (String) settings.get("category");
} else {
return "";
}
}

public String getTitle() {
var liveDSL = getLiveApplicationDsl();
if(liveDSL == null || liveDSL.get("settings") == null) return "";
Object settingsObject = liveDSL.get("settings");
if (settingsObject instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> settings = (Map<String, Object>) liveDSL.get("settings");
return (String) settings.get("title");
} else {
return "";
}
}

public String getDescription() {
var liveDSL = getLiveApplicationDsl();
if(liveDSL == null || liveDSL.get("settings") == null) return "";
Object settingsObject = liveDSL.get("settings");
if (settingsObject instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> settings = (Map<String, Object>) liveDSL.get("settings");
return (String) settings.get("description");
} else {
return "";
}
}

public Map<String, Object> getEditingApplicationDSLOrNull() {return editingApplicationDSL; }

public Mono<Object> getLiveContainerSize(ApplicationRecordService applicationRecordService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
public interface ApplicationRepository extends ReactiveMongoRepository<Application, String>, CustomApplicationRepository {

// publishedApplicationDSL : 0 -> excludes publishedApplicationDSL from the return
@Aggregation(pipeline = {"{ $match: { organizationId: ?0 } }", "{ $project: { 'editingApplicationDSL.settings.category': 1, _id: 1, gid: 1, organizationId: 1, name: 1, applicationType: 1, applicationStatus: 1, publicToAll: 1, publicToMarketplace: 1, agencyProfile: 1, editingUserId: 1, lastEditedAt: 1, createdAt: 1, updatedAt: 1, createdBy: 1, modifiedBy: 1, _class: 1}}"})
@Aggregation(pipeline = {"{ $match: { organizationId: ?0 } }", "{ $project: { 'editingApplicationDSL.settings': 1, _id: 1, gid: 1, organizationId: 1, name: 1, applicationType: 1, applicationStatus: 1, publicToAll: 1, publicToMarketplace: 1, agencyProfile: 1, editingUserId: 1, lastEditedAt: 1, createdAt: 1, updatedAt: 1, createdBy: 1, modifiedBy: 1, _class: 1}}"})
Flux<Application> findByOrganizationId(String organizationId);


@Override
@Nonnull
@Aggregation(pipeline = {"{ $match: { _id: ?0 } }", "{ $project: { 'editingApplicationDSL.settings.category': 1, _id: 1, gid: 1, organizationId: 1, name: 1, applicationType: 1, applicationStatus: 1, publicToAll: 1, publicToMarketplace: 1, agencyProfile: 1, editingUserId: 1, lastEditedAt: 1, createdAt: 1, updatedAt: 1, createdBy: 1, modifiedBy: 1, _class: 1}}"})
@Aggregation(pipeline = {"{ $match: { _id: ?0 } }", "{ $project: { 'editingApplicationDSL.settings': 1, _id: 1, gid: 1, organizationId: 1, name: 1, applicationType: 1, applicationStatus: 1, publicToAll: 1, publicToMarketplace: 1, agencyProfile: 1, editingUserId: 1, lastEditedAt: 1, createdAt: 1, updatedAt: 1, createdBy: 1, modifiedBy: 1, _class: 1}}"})
Mono<Application> findById(@Nonnull String id);

@Aggregation(pipeline = {"{ $match: { gid: ?0 } }", "{ $project: { 'editingApplicationDSL.settings.category': 1, _id: 1, gid: 1, organizationId: 1, name: 1, applicationType: 1, applicationStatus: 1, publicToAll: 1, publicToMarketplace: 1, agencyProfile: 1, editingUserId: 1, lastEditedAt: 1, createdAt: 1, updatedAt: 1, createdBy: 1, modifiedBy: 1, _class: 1}}"})
@Aggregation(pipeline = {"{ $match: { gid: ?0 } }", "{ $project: { 'editingApplicationDSL.settings': 1, _id: 1, gid: 1, organizationId: 1, name: 1, applicationType: 1, applicationStatus: 1, publicToAll: 1, publicToMarketplace: 1, agencyProfile: 1, editingUserId: 1, lastEditedAt: 1, createdAt: 1, updatedAt: 1, createdBy: 1, modifiedBy: 1, _class: 1}}"})
Flux<Application> findByGid(@Nonnull String gid);

Mono<Long> countByOrganizationIdAndApplicationStatus(String organizationId, ApplicationStatus applicationStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public class ApplicationInfoView {

private final String editingUserId;

@JsonInclude(Include.NON_NULL)
private final String title;
@JsonInclude(Include.NON_NULL)
private final String description;
@JsonInclude(Include.NON_NULL)
private final String category;

public long getLastViewTime() {
return lastViewTime == null ? 0 : lastViewTime.toEpochMilli();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ private Mono<ApplicationInfoView> buildView(Application application, ResourceRol
.applicationGid(application.getGid())
.orgId(application.getOrganizationId())
.name(application.getName())
.title(application.getTitle())
.description(application.getDescription())
.category(application.getCategory())
.createBy(Optional.ofNullable(userMap.get(application.getCreatedBy()))
.map(User::getName)
.orElse(""))
Expand Down

0 comments on commit 730d794

Please sign in to comment.