Skip to content

Commit

Permalink
issue #1155 Move "getOperationById()" to Foxx
Browse files Browse the repository at this point in the history
  • Loading branch information
wajda committed Oct 3, 2024
1 parent d86b4ab commit ab540af
Show file tree
Hide file tree
Showing 26 changed files with 197 additions and 102 deletions.
57 changes: 37 additions & 20 deletions arangodb-foxx-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,43 @@
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>gen-persistence-model</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<arguments combine.children="append">
<argument>--out</argument>
<argument>${project.basedir}/target/generated-ts/persistence-api.model.ts</argument>

<!-- Persistence model -->
<argument>za.co.absa.spline.persistence.model.ExecutionPlanPersistentModel</argument>
<argument>za.co.absa.spline.persistence.model.Progress</argument>
<argument>za.co.absa.spline.persistence.model.DataSource</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>gen-consumer-model</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<arguments combine.children="append">
<argument>--out</argument>
<argument>${project.basedir}/target/generated-ts/consumer-api.model.ts</argument>

<!-- Consumer model -->
<argument>za.co.absa.spline.consumer.service.model.Frame</argument>
<argument>za.co.absa.spline.consumer.service.model.ExecutionPlanInfo</argument>
<argument>za.co.absa.spline.consumer.service.model.ExecutionEventInfo</argument>
<argument>za.co.absa.spline.consumer.service.model.Label</argument>
<argument>za.co.absa.spline.consumer.service.model.DataSourceActionType</argument>
<argument>za.co.absa.spline.consumer.service.model.OperationDetails</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
Expand All @@ -50,31 +83,11 @@
</executableDependency>
<mainClass>com.mpc.scalats.CLI</mainClass>
<arguments>
<argument>--out</argument>
<argument>${project.basedir}/target/generated-ts/api.model.ts</argument>
<argument>--trait-to-type</argument>
<argument>--option-to-nullable</argument>
<argument>--string-single-quotes</argument>
<argument>--indent-size</argument>
<argument>4</argument>

<!-- ================================================ -->
<!-- list of root entities to generate TS definitions -->
<!-- ================================================ -->

<!-- Persistence model -->
<argument>za.co.absa.spline.persistence.model.Progress</argument>
<argument>za.co.absa.spline.persistence.model.DataSource</argument>

<!-- Producer model -->
<argument>za.co.absa.spline.producer.service.model.ExecutionPlanPersistentModel</argument>

<!-- Consumer model -->
<argument>za.co.absa.spline.consumer.service.model.Frame</argument>
<argument>za.co.absa.spline.consumer.service.model.ExecutionPlanInfo</argument>
<argument>za.co.absa.spline.consumer.service.model.ExecutionEventInfo</argument>
<argument>za.co.absa.spline.consumer.service.model.Label</argument>
<argument>za.co.absa.spline.consumer.service.model.DataSourceActionType</argument>
</arguments>
</configuration>
<dependencies>
Expand Down Expand Up @@ -120,5 +133,9 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package za.co.absa.spline.consumer.service.model


import com.fasterxml.jackson.core.`type`.TypeReference
import io.swagger.annotations.{ApiModel, ApiModelProperty}

@ApiModel(description = "Information Details of an Operation containing the input and output schemas with the description of the dataTypes")
Expand All @@ -32,3 +33,7 @@ case class OperationDetails
@ApiModelProperty(value = "Index of the schemas Array. The schema at this index represents the output schemas")
output: Int
)

object OperationDetails {
implicit val typeRef: TypeReference[OperationDetails] = new TypeReference[OperationDetails] {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
* Copyright 2020 ABSA Group Limited
*
* Copyright 2024 ABSA Group Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -29,6 +28,7 @@ import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}
))
sealed trait DataType {
def id: String

def nullable: Boolean
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
* Copyright 2022 ABSA Group Limited
*
* Copyright 2024 ABSA Group Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -14,9 +13,7 @@
* limitations under the License.
*/

package za.co.absa.spline.producer.service.model

import za.co.absa.spline.persistence.model._
package za.co.absa.spline.persistence.model

case class ExecutionPlanPersistentModel(

Expand Down
2 changes: 1 addition & 1 deletion arangodb-foxx-services/src/main/persistence/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


import { DocumentKey } from '../model'
import { ExecutionPlan, Progress } from '../../external/api.model'
import { ExecutionPlan, Progress } from '../../external/persistence-api.model'
import Document = ArangoDB.Document


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { createRouter } from '@arangodb/foxx'
import { DataSource } from '../../external/api.model'
import { DataSource } from '../../external/persistence-api.model'
import { storeDataSources } from '../services/data-source-store'


Expand Down
2 changes: 1 addition & 1 deletion arangodb-foxx-services/src/main/routes/events-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Joi from 'joi'

import { lineageOverview } from '../services/lineage-overview'
import { impactOverview } from '../services/impact-overview'
import { Progress } from '../../external/api.model'
import { Progress } from '../../external/persistence-api.model'
import {
checkExecutionEventExists,
listExecutionEventInfo_groupedByDataSource,
Expand Down
2 changes: 2 additions & 0 deletions arangodb-foxx-services/src/main/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { adminRouter } from './admin-router'
import { plansRouter } from './plans-router'
import { eventsRouter } from './events-router'
import { dsRouter } from './data-sources-router'
import { operationsRouter } from './operations-router'
import { RequestLogger } from '../middleware/request-logger.middleware'


Expand All @@ -34,5 +35,6 @@ rootRouter.use('/admin', adminRouter)
rootRouter.use('/execution-plans', plansRouter)
rootRouter.use('/execution-events', eventsRouter)
rootRouter.use('/data-sources', dsRouter)
rootRouter.use('/operations', operationsRouter)

export default rootRouter
37 changes: 37 additions & 0 deletions arangodb-foxx-services/src/main/routes/operations-router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2022 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { createRouter } from '@arangodb/foxx'
import Joi from 'joi'
import { getOperationById } from '../services/operation-store'
import { OperationDetails } from '../../external/consumer-api.model'


export const operationsRouter: Foxx.Router = createRouter()


// Get operation details
operationsRouter
.get('/:operationId',
(req: Foxx.Request, res: Foxx.Response) => {
const opDetails: OperationDetails = getOperationById(
req.pathParams.operationId
)
res.send(opDetails)
})
.pathParam('operationId', Joi.string().min(1).required(), 'Operation ID')
.response(200, ['application/json'], 'Operation details')
.summary('Get operation details by ID')
3 changes: 2 additions & 1 deletion arangodb-foxx-services/src/main/routes/plans-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

import { createRouter } from '@arangodb/foxx'
import { DataSourceActionType, ExecutionPlanPersistentModel } from '../../external/api.model'
import { ExecutionPlanPersistentModel } from '../../external/persistence-api.model'
import { DataSourceActionType } from '../../external/consumer-api.model'
import { checkExecutionPlanExists, getDataSourceURIsByActionType, storeExecutionPlan } from '../services/execution-plan-store'
import Joi from 'joi'

Expand Down
2 changes: 1 addition & 1 deletion arangodb-foxx-services/src/main/services/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { aql, db } from '@arangodb'
import { memoize } from '../utils/common'
import { GraphBuilder } from '../utils/graph'
import { ReadTxInfo } from '../persistence/model'
import { Progress } from '../../external/api.model'
import { Progress } from '../../external/persistence-api.model'
import { AQLCodeGenHelper } from '../utils/aql-gen-helper'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import * as api from '../../external/api.model'
import * as api from '../../external/persistence-api.model'
import { withTimeTracking } from '../utils/common'
import { aql, db } from '@arangodb'
import { NodeCollectionName } from '../persistence/model'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/


import { ExecPlanDetails, ExecutionEventInfo, Frame, Label, Progress } from '../../external/api.model'
import { ExecPlanDetails, Progress } from '../../external/persistence-api.model'
import { ExecutionEventInfo, Frame, Label } from '../../external/consumer-api.model'
import { CollectionName, edge, NodeCollectionName, ViewName, WriteTxInfo } from '../persistence/model'
import { checkKeyExistence, store } from '../persistence/store'
import { aql, db } from '@arangodb'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/


import { DataSourceActionType, ExecutionPlanPersistentModel } from '../../external/api.model'
import { ExecutionPlanPersistentModel } from '../../external/persistence-api.model'
import { DataSourceActionType } from '../../external/consumer-api.model'
import { CollectionName, EdgeCollectionName, NodeCollectionName, WriteTxInfo } from '../persistence/model'
import { checkKeyExistence, store } from '../persistence/store'
import { withTimeTracking } from '../utils/common'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
getExecutionEventFromEventKey,
getTargetDataSourceFromExecutionEvent
} from './commons'
import { Progress } from '../../external/api.model'
import { Progress } from '../../external/persistence-api.model'
import { ReadTxInfo } from '../persistence/model'
import { TxManager } from '../persistence/txm'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
getExecutionEventFromEventKey,
getTargetDataSourceFromExecutionEvent
} from './commons'
import { Progress } from '../../external/api.model'
import { Progress } from '../../external/persistence-api.model'
import { ReadTxInfo } from '../persistence/model'
import { TxManager } from '../persistence/txm'

Expand Down
2 changes: 1 addition & 1 deletion arangodb-foxx-services/src/main/services/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { DataSourceActionType } from '../../external/api.model'
import { DataSourceActionType } from '../../external/consumer-api.model'


export type DataSourceActionTypeValue = typeof DataSourceActionType.values[number]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { aql, db } from '@arangodb'
import { Progress } from '../../external/api.model'
import { Progress } from '../../external/persistence-api.model'
import { ReadTxInfo } from '../persistence/model'
import { AQLCodeGenHelper } from '../utils/aql-gen-helper'
import * as Logger from '../utils/logger'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { aql, db } from '@arangodb'
import { Progress } from '../../external/api.model'
import { Progress } from '../../external/persistence-api.model'
import { ReadTxInfo } from '../persistence/model'
import { AQLCodeGenHelper } from '../utils/aql-gen-helper'
import * as Logger from '../utils/logger'
Expand Down
Loading

0 comments on commit ab540af

Please sign in to comment.