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 committed Dec 5, 2024
1 parent 18e2917 commit e0b7317
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 @@ -180,17 +180,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 Object getLiveContainerSize() {
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 ApplicationInfoView buildView(Application application, ResourceRole maxR
.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 e0b7317

Please sign in to comment.