diff --git a/bootstrap/sql/migrations/native/1.5.0/mysql/postDataMigrationSQLScript.sql b/bootstrap/sql/migrations/native/1.5.0/mysql/postDataMigrationSQLScript.sql index 7b1d6e095d48..a701afc772d8 100644 --- a/bootstrap/sql/migrations/native/1.5.0/mysql/postDataMigrationSQLScript.sql +++ b/bootstrap/sql/migrations/native/1.5.0/mysql/postDataMigrationSQLScript.sql @@ -22,4 +22,13 @@ WHERE name IN ( 'columnValuesSumToBeBetween', 'columnValuesToBeBetween', 'tableRowCountToBeBetween' -); \ No newline at end of file +); + +-- Update schedule type for applications +UPDATE installed_apps +SET json = JSON_MERGE_PATCH(json, '{"scheduleType": "ScheduledOrManual"}') +WHERE JSON_UNQUOTE(json->'$.scheduleType') = 'Scheduled'; + +-- recreate all scheduled apps +DELETE FROM apps_marketplace +WHERE JSON_UNQUOTE(json->'$.scheduleType') = 'Scheduled'; diff --git a/bootstrap/sql/migrations/native/1.5.0/postgres/postDataMigrationSQLScript.sql b/bootstrap/sql/migrations/native/1.5.0/postgres/postDataMigrationSQLScript.sql index 85af0338b845..295e6593ddbd 100644 --- a/bootstrap/sql/migrations/native/1.5.0/postgres/postDataMigrationSQLScript.sql +++ b/bootstrap/sql/migrations/native/1.5.0/postgres/postDataMigrationSQLScript.sql @@ -23,3 +23,11 @@ WHERE name IN ( 'tableRowCountToBeBetween' ); +-- Update schedule type for applications +UPDATE installed_apps +SET json = json || '{"scheduleType": "ScheduledOrManual"}' +WHERE json->>'scheduleType' = 'Scheduled'; + +-- recreate all scheduled apps +DELETE FROM apps_marketplace +WHERE json->>'scheduleType' = 'Scheduled'; \ No newline at end of file diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java b/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java index 130abb1db109..80a14f2d221e 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/apps/AbstractNativeApplication.java @@ -2,7 +2,7 @@ import static org.openmetadata.service.apps.scheduler.AbstractOmAppJobListener.JOB_LISTENER_NAME; import static org.openmetadata.service.apps.scheduler.AppScheduler.APP_NAME; -import static org.openmetadata.service.exception.CatalogExceptionMessage.LIVE_APP_SCHEDULE_ERR; +import static org.openmetadata.service.exception.CatalogExceptionMessage.NO_MANUAL_TRIGGER_ERR; import java.util.List; import lombok.Getter; @@ -90,13 +90,13 @@ public void install() { @Override public void triggerOnDemand() { // Validate Native Application - if (app.getScheduleType().equals(ScheduleType.Scheduled)) { + if (app.getScheduleType().equals(ScheduleType.ScheduledOrManual)) { AppRuntime runtime = getAppRuntime(app); validateServerExecutableApp(runtime); // Trigger the application AppScheduler.getInstance().triggerOnDemandApplication(app); } else { - throw new IllegalArgumentException(LIVE_APP_SCHEDULE_ERR); + throw new IllegalArgumentException(NO_MANUAL_TRIGGER_ERR); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java b/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java index 1263269beb65..443caed5e133 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/exception/CatalogExceptionMessage.java @@ -99,7 +99,7 @@ public final class CatalogExceptionMessage { public static final String TOKEN_EXPIRY_ERROR = "Email Verification Token %s is expired. Please issue a new request for email verification."; public static final String INVALID_BOT_USER = "Revoke Token can only be applied to Bot Users."; - public static final String LIVE_APP_SCHEDULE_ERR = "Live Application cannot scheduled."; + public static final String NO_MANUAL_TRIGGER_ERR = "App does not support manual trigger."; public static final String INVALID_APP_TYPE = "Application Type is not valid."; private CatalogExceptionMessage() {} diff --git a/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsApplication.json b/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsApplication.json index 452391f940da..59470bea43b9 100644 --- a/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsApplication.json +++ b/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsApplication.json @@ -9,7 +9,7 @@ "developerUrl": "https://www.getcollate.io", "privacyPolicyUrl": "https://www.getcollate.io", "supportEmail": "support@getcollate.io", - "scheduleType": "Scheduled", + "scheduleType": "ScheduledOrManual", "permission": "All", "className": "org.openmetadata.service.apps.bundles.insights.DataInsightsApp", "runtime": { diff --git a/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsReportApplication.json b/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsReportApplication.json index 34353d31d59a..f371834234d4 100644 --- a/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsReportApplication.json +++ b/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/DataInsightsReportApplication.json @@ -9,7 +9,7 @@ "developerUrl": "https://www.getcollate.io", "privacyPolicyUrl": "https://www.getcollate.io", "supportEmail": "support@getcollate.io", - "scheduleType": "Scheduled", + "scheduleType": "ScheduledOrManual", "permission": "All", "className": "org.openmetadata.service.apps.bundles.insights.DataInsightsReportApp", "runtime": { diff --git a/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/SearchIndexingApplication.json b/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/SearchIndexingApplication.json index 2dd3c5eec87b..d12c0a8fc564 100644 --- a/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/SearchIndexingApplication.json +++ b/openmetadata-service/src/main/resources/json/data/appMarketPlaceDefinition/SearchIndexingApplication.json @@ -9,7 +9,7 @@ "developerUrl": "https://www.getcollate.io", "privacyPolicyUrl": "https://www.getcollate.io", "supportEmail": "support@getcollate.io", - "scheduleType": "Scheduled", + "scheduleType": "ScheduledOrManual", "permission": "All", "className": "org.openmetadata.service.apps.bundles.searchIndex.SearchIndexApp", "runtime": { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/apps/AppsResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/apps/AppsResourceTest.java index 8ffd3dd1b4d9..ce4d65cb1504 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/apps/AppsResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/apps/AppsResourceTest.java @@ -108,6 +108,14 @@ void post_trigger_app_200() throws HttpResponseException, InterruptedException { } } + @Test + void post_trigger_no_trigger_app_400() { + assertResponseContains( + () -> postTriggerApp("ExampleAppNoTrigger", ADMIN_AUTH_HEADERS), + BAD_REQUEST, + "App does not support manual trigger."); + } + @Override public void validateCreatedEntity( App createdEntity, CreateApp request, Map authHeaders) diff --git a/openmetadata-service/src/test/resources/json/data/app/ExampleAppNoTrigger.json b/openmetadata-service/src/test/resources/json/data/app/ExampleAppNoTrigger.json new file mode 100644 index 000000000000..80189a929ec3 --- /dev/null +++ b/openmetadata-service/src/test/resources/json/data/app/ExampleAppNoTrigger.json @@ -0,0 +1,9 @@ +{ + "name": "ExampleAppNoTrigger", + "displayName": "Example App No Trigger", + "appConfiguration": {}, + "appSchedule": { + "scheduleTimeline": "Custom", + "cronExpression": "0 0 1/1 * *" + } +} \ No newline at end of file diff --git a/openmetadata-service/src/test/resources/json/data/appMarketPlaceDefinition/ExampleAppNoTrigger.json b/openmetadata-service/src/test/resources/json/data/appMarketPlaceDefinition/ExampleAppNoTrigger.json new file mode 100644 index 000000000000..dbd02bf8e862 --- /dev/null +++ b/openmetadata-service/src/test/resources/json/data/appMarketPlaceDefinition/ExampleAppNoTrigger.json @@ -0,0 +1,20 @@ +{ + "name": "ExampleAppNoTrigger", + "displayName": "Example App No Trigger", + "description": "An example app without manual trigger.", + "features": "Dont try this at home.", + "appType": "internal", + "appScreenshots": [ + ], + "developer": "ACME Labs", + "developerUrl": "https://www.example.com", + "privacyPolicyUrl": "https://www.example.com", + "supportEmail": "use@example.com", + "scheduleType": "Scheduled", + "permission": "All", + "className": "org.openmetadata.service.apps.bundles.searchIndex.SearchIndexApp", + "runtime": { + "enabled": true + }, + "appConfiguration": {} +} diff --git a/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json b/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json index 98a6cf6c41c3..9badba82c7d2 100644 --- a/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json +++ b/openmetadata-spec/src/main/resources/json/schema/entity/applications/app.json @@ -13,7 +13,8 @@ "type": "string", "enum": [ "Live", - "Scheduled" + "Scheduled", + "ScheduledOrManual" ], "javaEnums": [ { @@ -21,6 +22,9 @@ }, { "name": "Scheduled" + }, + { + "name": "ScheduledOrManual" } ] },