@things-factory/process 8.0.0 → 9.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/client/actions/main.ts +0 -1
- package/client/bootstrap.ts +0 -8
- package/client/index.ts +0 -1
- package/client/pages/event/event-importer.ts +0 -86
- package/client/pages/event/event-list-page.ts +0 -324
- package/client/pages/gateway/gateway-importer.ts +0 -87
- package/client/pages/gateway/gateway-list-page.ts +0 -323
- package/client/pages/main.ts +0 -25
- package/client/pages/process/process-importer.ts +0 -87
- package/client/pages/process/process-list-page.ts +0 -324
- package/client/pages/process-instance/process-instance-importer.ts +0 -87
- package/client/pages/process-instance/process-instance-list-page.ts +0 -323
- package/client/pages/process-thread/process-thread-importer.ts +0 -87
- package/client/pages/process-thread/process-thread-list-page.ts +0 -323
- package/client/reducers/main.ts +0 -17
- package/client/route.ts +0 -27
- package/client/tsconfig.json +0 -13
- package/server/controllers/common.ts +0 -90
- package/server/controllers/index.ts +0 -0
- package/server/controllers/process-instance/abort.ts +0 -75
- package/server/controllers/process-instance/end.ts +0 -74
- package/server/controllers/process-instance/index.ts +0 -2
- package/server/controllers/process-thread/_abort.ts +0 -20
- package/server/controllers/process-thread/abort.ts +0 -48
- package/server/controllers/process-thread/end.ts +0 -54
- package/server/controllers/process-thread/index.ts +0 -3
- package/server/controllers/process-thread/start.ts +0 -49
- package/server/index.ts +0 -4
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -80
- package/server/service/index.ts +0 -44
- package/server/service/process/event-subscriber.ts +0 -17
- package/server/service/process/index.ts +0 -9
- package/server/service/process/process-history.ts +0 -108
- package/server/service/process/process-mutation.ts +0 -210
- package/server/service/process/process-query.ts +0 -120
- package/server/service/process/process-search-key-item-type.ts +0 -16
- package/server/service/process/process-type.ts +0 -65
- package/server/service/process/process.ts +0 -97
- package/server/service/process-instance/event-subscriber.ts +0 -44
- package/server/service/process-instance/index.ts +0 -10
- package/server/service/process-instance/process-instance-history.ts +0 -154
- package/server/service/process-instance/process-instance-mutation.ts +0 -33
- package/server/service/process-instance/process-instance-query.ts +0 -141
- package/server/service/process-instance/process-instance-subscription.ts +0 -46
- package/server/service/process-instance/process-instance-type.ts +0 -71
- package/server/service/process-instance/process-instance.ts +0 -147
- package/server/service/process-stats/index.ts +0 -3
- package/server/service/process-stats/process-stats-query.ts +0 -57
- package/server/service/process-stats/process-stats-type.ts +0 -31
- package/server/service/process-thread/event-subscriber.ts +0 -31
- package/server/service/process-thread/index.ts +0 -9
- package/server/service/process-thread/process-thread-mutation.ts +0 -34
- package/server/service/process-thread/process-thread-query.ts +0 -61
- package/server/service/process-thread/process-thread-subscription.ts +0 -42
- package/server/service/process-thread/process-thread-type.ts +0 -15
- package/server/service/process-thread/process-thread.ts +0 -90
- package/server/tsconfig.json +0 -10
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ProcessThread, ProcessThreadStatus } from '../../service/process-thread/process-thread'
|
|
2
|
-
import { updateProcessInstanceState } from '../common'
|
|
3
|
-
|
|
4
|
-
export async function end(
|
|
5
|
-
{ id, output, reason }: { id: string; output?: object; reason?: string },
|
|
6
|
-
context: ResolverContext
|
|
7
|
-
): Promise<ProcessThread> {
|
|
8
|
-
const { domain, user, tx } = context.state
|
|
9
|
-
|
|
10
|
-
const repository = tx.getRepository(ProcessThread)
|
|
11
|
-
|
|
12
|
-
var processThread = await repository.findOne({
|
|
13
|
-
where: { domain: { id: domain.id }, id }
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
if (!processThread) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
context.t('error.process-thread not found', {
|
|
19
|
-
processThread: id
|
|
20
|
-
})
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
Prerequisites for a process thread to Be End.
|
|
26
|
-
- The previous state of the process thread must not be End or End.
|
|
27
|
-
*/
|
|
28
|
-
if (
|
|
29
|
-
processThread.state == ProcessThreadStatus.Aborted ||
|
|
30
|
-
processThread.state == ProcessThreadStatus.Ended ||
|
|
31
|
-
processThread.state == ProcessThreadStatus.Delegated
|
|
32
|
-
) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
context.t(`error.process-thread is already terminated`, {
|
|
35
|
-
id,
|
|
36
|
-
actual: processThread.state
|
|
37
|
-
})
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
processThread = await repository.save({
|
|
42
|
-
...processThread,
|
|
43
|
-
reason,
|
|
44
|
-
output,
|
|
45
|
-
transaction: 'end',
|
|
46
|
-
state: ProcessThreadStatus.Ended,
|
|
47
|
-
updater: user,
|
|
48
|
-
terminatedAt: new Date()
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
await updateProcessInstanceState(processThread.processInstanceId, context)
|
|
52
|
-
|
|
53
|
-
return processThread
|
|
54
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ProcessThread, ProcessThreadStatus } from '../../service/process-thread/process-thread'
|
|
2
|
-
import { updateProcessInstanceState } from '../common'
|
|
3
|
-
|
|
4
|
-
export async function start(
|
|
5
|
-
id: string,
|
|
6
|
-
output: object,
|
|
7
|
-
reason: string,
|
|
8
|
-
context: ResolverContext
|
|
9
|
-
): Promise<ProcessThread> {
|
|
10
|
-
const { domain, user, tx } = context.state
|
|
11
|
-
|
|
12
|
-
const repository = tx.getRepository(ProcessThread)
|
|
13
|
-
const processThread = await repository.findOne({
|
|
14
|
-
where: { domain: { id: domain.id }, id }
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
if (!processThread) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
context.t('error.process-thread not found', {
|
|
20
|
-
processThread: id
|
|
21
|
-
})
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
Prerequisites for a process thread to Be Started.
|
|
27
|
-
- The previous state of the process thread must not be terminated.
|
|
28
|
-
*/
|
|
29
|
-
if (processThread.state !== ProcessThreadStatus.Assigned) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
context.t(`error.process-thread should not be started`, {
|
|
32
|
-
id,
|
|
33
|
-
actual: processThread.state
|
|
34
|
-
})
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const result = await tx.getRepository(ProcessThread).save({
|
|
39
|
-
...processThread,
|
|
40
|
-
reason,
|
|
41
|
-
state: ProcessThreadStatus.Started,
|
|
42
|
-
transaction: 'start',
|
|
43
|
-
updater: user
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
await updateProcessInstanceState(processThread.processInstanceId, context)
|
|
47
|
-
|
|
48
|
-
return result
|
|
49
|
-
}
|
package/server/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const glob = require('glob')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
export var migrations = []
|
|
5
|
-
|
|
6
|
-
glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
|
|
7
|
-
if (file.indexOf('index.js') !== -1) return
|
|
8
|
-
migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
|
|
9
|
-
})
|
package/server/routes.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
const debug = require('debug')('things-factory:process:routes')
|
|
2
|
-
|
|
3
|
-
process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
|
|
4
|
-
/*
|
|
5
|
-
* can add global public routes to application (auth not required, tenancy not required)
|
|
6
|
-
*
|
|
7
|
-
* ex) routes.get('/path', async(context, next) => {})
|
|
8
|
-
* ex) routes.post('/path', async(context, next) => {})
|
|
9
|
-
*/
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
|
|
13
|
-
/*
|
|
14
|
-
* can add global private routes to application (auth required, tenancy not required)
|
|
15
|
-
*/
|
|
16
|
-
/* When a callback occurs from the scheduler when a scheduled dataset is on schedule, data collection task for the dataset should be issued. */
|
|
17
|
-
// globalPrivateRouter.post('/callback-schedule-for-start-event', async (context, next) => {
|
|
18
|
-
// const { client } = context.request.body as ScheduleRegisterRequest
|
|
19
|
-
// if (!client || typeof client !== 'object') {
|
|
20
|
-
// throw new Error('client property should be a part of callback body.')
|
|
21
|
-
// }
|
|
22
|
-
// const { group: domainId, key: dataSetId } = client
|
|
23
|
-
// if (!domainId || !dataSetId) {
|
|
24
|
-
// throw new Error(`group(${domainId}) and key(${dataSetId}) properties should not be empty`)
|
|
25
|
-
// }
|
|
26
|
-
// await getDataSource().transaction(async tx => {
|
|
27
|
-
// const domain = await tx.getRepository(Domain).findOneBy({ id: domainId })
|
|
28
|
-
// if (!domain) {
|
|
29
|
-
// throw new Error(`domain(${domainId}) not found`)
|
|
30
|
-
// }
|
|
31
|
-
// const dataSet = await tx.getRepository(DataSet).findOne({ where: { domain: { id: domainId }, id: dataSetId } })
|
|
32
|
-
// const activity = (await tx.getRepository(Activity).findOneBy({
|
|
33
|
-
// domain: { id: domainId },
|
|
34
|
-
// name: 'Collect Data'
|
|
35
|
-
// })) as Activity
|
|
36
|
-
// if (activity) {
|
|
37
|
-
// const { assignees } = dataSet
|
|
38
|
-
// /* 해당 dataset에 대한 데이타 수집 태스크를 dataset assignees에게 할당한다. */
|
|
39
|
-
// if (assignees && assignees instanceof Array && assignees.length > 0) {
|
|
40
|
-
// const activityInstance = {
|
|
41
|
-
// name: `[Data 수집] ${dataSet.name}`,
|
|
42
|
-
// description: dataSet.description,
|
|
43
|
-
// activityId: activity.id,
|
|
44
|
-
// dueAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
|
|
45
|
-
// input: {
|
|
46
|
-
// dataSetId: dataSet.id,
|
|
47
|
-
// dataSetName: dataSet.name
|
|
48
|
-
// },
|
|
49
|
-
// assignees
|
|
50
|
-
// }
|
|
51
|
-
// context.state = {
|
|
52
|
-
// ...context.state,
|
|
53
|
-
// domain,
|
|
54
|
-
// tx
|
|
55
|
-
// }
|
|
56
|
-
// await issue(activityInstance, context)
|
|
57
|
-
// } else {
|
|
58
|
-
// throw new Error(
|
|
59
|
-
// `Assignees not set. So Data Collect Activity for ${dataSet.name}($dataSet.id) could not be issued.`
|
|
60
|
-
// )
|
|
61
|
-
// }
|
|
62
|
-
// } else {
|
|
63
|
-
// throw new Error(`Data Collect Activity is not installed.`)
|
|
64
|
-
// }
|
|
65
|
-
// })
|
|
66
|
-
// context.status = 200
|
|
67
|
-
// })
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
|
|
71
|
-
/*
|
|
72
|
-
* can add domain public routes to application (auth not required, tenancy required)
|
|
73
|
-
*/
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
77
|
-
/*
|
|
78
|
-
* can add domain private routes to application (auth required, tenancy required)
|
|
79
|
-
*/
|
|
80
|
-
})
|
package/server/service/index.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* EXPORT ENTITY TYPES */
|
|
2
|
-
export * from './process-thread/process-thread'
|
|
3
|
-
export * from './process-instance/process-instance'
|
|
4
|
-
export * from './process/process'
|
|
5
|
-
|
|
6
|
-
/* IMPORT ENTITIES AND RESOLVERS */
|
|
7
|
-
import {
|
|
8
|
-
entities as ProcessThreadEntities,
|
|
9
|
-
resolvers as ProcessThreadResolvers,
|
|
10
|
-
subscribers as ProcessThreadSubscribers
|
|
11
|
-
} from './process-thread'
|
|
12
|
-
import {
|
|
13
|
-
entities as ProcessInstanceEntities,
|
|
14
|
-
resolvers as ProcessInstanceResolvers,
|
|
15
|
-
subscribers as ProcessInstanceSubscribers
|
|
16
|
-
} from './process-instance'
|
|
17
|
-
import {
|
|
18
|
-
entities as ProcessEntities,
|
|
19
|
-
resolvers as ProcessResolvers,
|
|
20
|
-
subscribers as ProcessSubscribers
|
|
21
|
-
} from './process'
|
|
22
|
-
|
|
23
|
-
export const entities = [
|
|
24
|
-
/* ENTITIES */
|
|
25
|
-
...ProcessThreadEntities,
|
|
26
|
-
...ProcessInstanceEntities,
|
|
27
|
-
...ProcessEntities
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
export const subscribers = [
|
|
31
|
-
/* SUBSCRIBERS */
|
|
32
|
-
...ProcessThreadSubscribers,
|
|
33
|
-
...ProcessInstanceSubscribers,
|
|
34
|
-
...ProcessSubscribers
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
-
export const schema = {
|
|
38
|
-
resolverClasses: [
|
|
39
|
-
/* RESOLVER CLASSES */
|
|
40
|
-
...ProcessThreadResolvers,
|
|
41
|
-
...ProcessInstanceResolvers,
|
|
42
|
-
...ProcessResolvers
|
|
43
|
-
]
|
|
44
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { HistoryEntitySubscriber } from '@operato/typeorm-history'
|
|
4
|
-
|
|
5
|
-
import { Process } from './process'
|
|
6
|
-
import { ProcessHistory } from './process-history'
|
|
7
|
-
|
|
8
|
-
@EventSubscriber()
|
|
9
|
-
export class ProcessHistoryEntitySubscriber extends HistoryEntitySubscriber<Process, ProcessHistory> {
|
|
10
|
-
public get entity() {
|
|
11
|
-
return Process
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public get historyEntity() {
|
|
15
|
-
return ProcessHistory
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Process } from './process'
|
|
2
|
-
import { ProcessHistory } from './process-history'
|
|
3
|
-
import { ProcessMutation } from './process-mutation'
|
|
4
|
-
import { ProcessQuery } from './process-query'
|
|
5
|
-
import { ProcessHistoryEntitySubscriber } from './event-subscriber'
|
|
6
|
-
|
|
7
|
-
export const entities = [Process, ProcessHistory]
|
|
8
|
-
export const resolvers = [ProcessQuery, ProcessMutation]
|
|
9
|
-
export const subscribers = [ProcessHistoryEntitySubscriber]
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType } from 'type-graphql'
|
|
2
|
-
import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
HistoryActionColumn,
|
|
6
|
-
HistoryActionType,
|
|
7
|
-
HistoryEntityInterface,
|
|
8
|
-
HistoryOriginalIdColumn
|
|
9
|
-
} from '@operato/typeorm-history'
|
|
10
|
-
import { Role, User } from '@things-factory/auth-base'
|
|
11
|
-
import { config } from '@things-factory/env'
|
|
12
|
-
import { Domain } from '@things-factory/shell'
|
|
13
|
-
|
|
14
|
-
import { Process, ProcessStatus } from './process'
|
|
15
|
-
|
|
16
|
-
const ORMCONFIG = config.get('ormconfig', {})
|
|
17
|
-
const DATABASE_TYPE = ORMCONFIG.type
|
|
18
|
-
|
|
19
|
-
@Entity()
|
|
20
|
-
@Index(
|
|
21
|
-
'ix_process_history_0',
|
|
22
|
-
(processHistory: ProcessHistory) => [processHistory.originalId, processHistory.version],
|
|
23
|
-
{ unique: true }
|
|
24
|
-
)
|
|
25
|
-
@Index(
|
|
26
|
-
'ix_process_history_1',
|
|
27
|
-
(processHistory: ProcessHistory) => [processHistory.domain, processHistory.originalId, processHistory.version],
|
|
28
|
-
{ unique: true }
|
|
29
|
-
)
|
|
30
|
-
@ObjectType({ description: 'History Entity of Process' })
|
|
31
|
-
export class ProcessHistory implements HistoryEntityInterface<Process> {
|
|
32
|
-
@PrimaryGeneratedColumn('uuid')
|
|
33
|
-
@Field(type => ID)
|
|
34
|
-
readonly id: string
|
|
35
|
-
|
|
36
|
-
@Column({ nullable: true, default: 1 })
|
|
37
|
-
@Field({ nullable: true })
|
|
38
|
-
version?: number = 1
|
|
39
|
-
|
|
40
|
-
@ManyToOne(type => Domain)
|
|
41
|
-
@Field(type => Domain)
|
|
42
|
-
domain?: Domain
|
|
43
|
-
|
|
44
|
-
@RelationId((process: Process) => process.domain)
|
|
45
|
-
domainId?: string
|
|
46
|
-
|
|
47
|
-
@Column()
|
|
48
|
-
@Field({ nullable: true })
|
|
49
|
-
name?: string
|
|
50
|
-
|
|
51
|
-
@Column({ nullable: true })
|
|
52
|
-
@Field({ nullable: true })
|
|
53
|
-
description?: string
|
|
54
|
-
|
|
55
|
-
@Column({ nullable: true })
|
|
56
|
-
@Field({ nullable: true })
|
|
57
|
-
state?: ProcessStatus
|
|
58
|
-
|
|
59
|
-
@ManyToOne(type => Role, { nullable: true })
|
|
60
|
-
@Field(type => Role, { nullable: true })
|
|
61
|
-
supervisoryRole?: Role
|
|
62
|
-
|
|
63
|
-
@RelationId((process: Process) => process.supervisoryRole)
|
|
64
|
-
supervisoryRoleId?: string
|
|
65
|
-
|
|
66
|
-
@Column()
|
|
67
|
-
@Field({ nullable: true })
|
|
68
|
-
createdAt?: Date
|
|
69
|
-
|
|
70
|
-
@Column()
|
|
71
|
-
@Field({ nullable: true })
|
|
72
|
-
updatedAt?: Date
|
|
73
|
-
|
|
74
|
-
@ManyToOne(type => User, { nullable: true })
|
|
75
|
-
@Field(type => User, { nullable: true })
|
|
76
|
-
creator?: User
|
|
77
|
-
|
|
78
|
-
@RelationId((process: Process) => process.creator)
|
|
79
|
-
creatorId?: string
|
|
80
|
-
|
|
81
|
-
@ManyToOne(type => User, { nullable: true })
|
|
82
|
-
@Field(type => User, { nullable: true })
|
|
83
|
-
updater?: User
|
|
84
|
-
|
|
85
|
-
@RelationId((process: Process) => process.updater)
|
|
86
|
-
updaterId?: string
|
|
87
|
-
|
|
88
|
-
@HistoryOriginalIdColumn()
|
|
89
|
-
public originalId!: string
|
|
90
|
-
|
|
91
|
-
@HistoryActionColumn({
|
|
92
|
-
nullable: false,
|
|
93
|
-
type:
|
|
94
|
-
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
95
|
-
? 'enum'
|
|
96
|
-
: DATABASE_TYPE == 'oracle'
|
|
97
|
-
? 'varchar2'
|
|
98
|
-
: DATABASE_TYPE == 'mssql'
|
|
99
|
-
? 'nvarchar'
|
|
100
|
-
: 'varchar',
|
|
101
|
-
enum:
|
|
102
|
-
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
103
|
-
? HistoryActionType
|
|
104
|
-
: undefined,
|
|
105
|
-
length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10
|
|
106
|
-
})
|
|
107
|
-
public action!: HistoryActionType
|
|
108
|
-
}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
|
5
|
-
import { Application, CallbackBase, registerSchedule, unregisterSchedule } from '@things-factory/scheduler-client'
|
|
6
|
-
|
|
7
|
-
import { Process } from './process'
|
|
8
|
-
import { ProcessPatch, NewProcess } from './process-type'
|
|
9
|
-
|
|
10
|
-
@Resolver(Process)
|
|
11
|
-
export class ProcessMutation {
|
|
12
|
-
@Directive('@transaction')
|
|
13
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
14
|
-
@Mutation(returns => Process, { description: 'To create new Process' })
|
|
15
|
-
async createProcess(@Arg('process') process: NewProcess, @Ctx() context: ResolverContext): Promise<Process> {
|
|
16
|
-
const { domain, user, tx } = context.state
|
|
17
|
-
|
|
18
|
-
const result = await tx.getRepository(Process).save({
|
|
19
|
-
...process,
|
|
20
|
-
domain,
|
|
21
|
-
creator: user,
|
|
22
|
-
updater: user
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
if (process.thumbnail) {
|
|
26
|
-
await createAttachment(
|
|
27
|
-
null,
|
|
28
|
-
{
|
|
29
|
-
attachment: {
|
|
30
|
-
file: process.thumbnail,
|
|
31
|
-
refType: Process.name,
|
|
32
|
-
refBy: result.id
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
context
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return result
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Directive('@transaction')
|
|
43
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
44
|
-
@Mutation(returns => Process, { description: 'To modify Process information' })
|
|
45
|
-
async updateProcess(
|
|
46
|
-
@Arg('id') id: string,
|
|
47
|
-
@Arg('patch') patch: ProcessPatch,
|
|
48
|
-
@Ctx() context: ResolverContext
|
|
49
|
-
): Promise<Process> {
|
|
50
|
-
const { domain, user, tx } = context.state
|
|
51
|
-
|
|
52
|
-
const repository = tx.getRepository(Process)
|
|
53
|
-
const process = await repository.findOne({
|
|
54
|
-
where: { domain: { id: domain.id }, id },
|
|
55
|
-
/* history에 항상 반영될 수 있도록 relations가 있어야 함. */
|
|
56
|
-
relations: ['domain', 'issuerRole', 'supervisoryRole', 'creator', 'updater']
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const result = await repository.save({
|
|
60
|
-
...process,
|
|
61
|
-
...patch,
|
|
62
|
-
updater: user
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
if (patch.thumbnail) {
|
|
66
|
-
await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
|
|
67
|
-
await createAttachment(
|
|
68
|
-
null,
|
|
69
|
-
{
|
|
70
|
-
attachment: {
|
|
71
|
-
file: patch.thumbnail,
|
|
72
|
-
refType: Process.name,
|
|
73
|
-
refBy: result.id
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
context
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return result
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@Directive('@transaction')
|
|
84
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
85
|
-
@Mutation(returns => [Process], { description: "To modify multiple Processes' information" })
|
|
86
|
-
async updateMultipleProcess(
|
|
87
|
-
@Arg('patches', type => [ProcessPatch]) patches: ProcessPatch[],
|
|
88
|
-
@Ctx() context: ResolverContext
|
|
89
|
-
): Promise<Process[]> {
|
|
90
|
-
const { domain, user, tx } = context.state
|
|
91
|
-
|
|
92
|
-
let results = []
|
|
93
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
94
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
95
|
-
const processRepo = tx.getRepository(Process)
|
|
96
|
-
|
|
97
|
-
if (_createRecords.length > 0) {
|
|
98
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
99
|
-
const newRecord = _createRecords[i]
|
|
100
|
-
|
|
101
|
-
const result = await processRepo.save({
|
|
102
|
-
...newRecord,
|
|
103
|
-
domain,
|
|
104
|
-
creator: user,
|
|
105
|
-
updater: user
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
if (newRecord.thumbnail) {
|
|
109
|
-
await createAttachment(
|
|
110
|
-
null,
|
|
111
|
-
{
|
|
112
|
-
attachment: {
|
|
113
|
-
file: newRecord.thumbnail,
|
|
114
|
-
refType: Process.name,
|
|
115
|
-
refBy: result.id
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
context
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
results.push({ ...result, cuFlag: '+' })
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (_updateRecords.length > 0) {
|
|
127
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
128
|
-
const updateRecord = _updateRecords[i]
|
|
129
|
-
const process = await processRepo.findOne({
|
|
130
|
-
where: { id: updateRecord.id },
|
|
131
|
-
/* history에 항상 반영될 수 있도록 relations가 있어야 함. */
|
|
132
|
-
relations: ['domain', 'issuerRole', 'supervisoryRole', 'creator', 'updater']
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
const result = await processRepo.save({
|
|
136
|
-
...process,
|
|
137
|
-
...updateRecord,
|
|
138
|
-
updater: user
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
if (updateRecord.thumbnail) {
|
|
142
|
-
await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
|
|
143
|
-
await createAttachment(
|
|
144
|
-
null,
|
|
145
|
-
{
|
|
146
|
-
attachment: {
|
|
147
|
-
file: updateRecord.thumbnail,
|
|
148
|
-
refType: Process.name,
|
|
149
|
-
refBy: result.id
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
context
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return results
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
@Directive('@transaction')
|
|
164
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
165
|
-
@Mutation(returns => Boolean, { description: 'To delete Process' })
|
|
166
|
-
async deleteProcess(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
167
|
-
const { domain, tx } = context.state
|
|
168
|
-
|
|
169
|
-
await tx.getRepository(Process).delete({ domain: { id: domain.id }, id })
|
|
170
|
-
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
171
|
-
|
|
172
|
-
return true
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@Directive('@transaction')
|
|
176
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple Processes' })
|
|
177
|
-
async deleteProcesses(
|
|
178
|
-
@Arg('ids', type => [String]) ids: string[],
|
|
179
|
-
@Ctx() context: ResolverContext
|
|
180
|
-
): Promise<boolean> {
|
|
181
|
-
const { domain, tx } = context.state
|
|
182
|
-
|
|
183
|
-
await tx.getRepository(Process).delete({
|
|
184
|
-
domain: { id: domain.id },
|
|
185
|
-
id: In(ids)
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
await deleteAttachmentsByRef(null, { refBys: ids }, context)
|
|
189
|
-
|
|
190
|
-
return true
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@Directive('@transaction')
|
|
194
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
195
|
-
@Mutation(returns => Boolean, { description: 'To import multiple Processes' })
|
|
196
|
-
async importProcesses(
|
|
197
|
-
@Arg('processes', type => [ProcessPatch]) processes: ProcessPatch[],
|
|
198
|
-
@Ctx() context: ResolverContext
|
|
199
|
-
): Promise<boolean> {
|
|
200
|
-
const { domain, tx } = context.state
|
|
201
|
-
|
|
202
|
-
await Promise.all(
|
|
203
|
-
processes.map(async (process: ProcessPatch) => {
|
|
204
|
-
const createdProcess: Process = await tx.getRepository(Process).save({ domain, ...process })
|
|
205
|
-
})
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
return true
|
|
209
|
-
}
|
|
210
|
-
}
|