@things-factory/dataset 5.0.0-alpha.18 → 5.0.0-alpha.20

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.
@@ -11,9 +11,23 @@ export class DataOocMutation {
11
11
  async createDataOoc(@Arg('dataOoc') dataOoc: NewDataOoc, @Ctx() context: any): Promise<DataOoc> {
12
12
  const { domain, user, tx } = context.state
13
13
 
14
+ const state = dataOoc.state || DataOocStatus.CREATED
15
+ const history = [
16
+ {
17
+ user: {
18
+ id: user.id,
19
+ name: user.name
20
+ },
21
+ state,
22
+ timestamp: Date.now()
23
+ }
24
+ ]
25
+
14
26
  return await tx.getRepository(DataOoc).save({
15
27
  ...dataOoc,
28
+ state,
16
29
  domain,
30
+ history,
17
31
  creator: user,
18
32
  updater: user
19
33
  })
@@ -30,88 +44,107 @@ export class DataOocMutation {
30
44
  where: { domain, id }
31
45
  })
32
46
 
47
+ const state = patch.state || dataOoc.state
48
+
49
+ const history = dataOoc.history || []
50
+ history.push({
51
+ user: {
52
+ id: user.id,
53
+ name: user.name
54
+ },
55
+ state,
56
+ comment: patch.correctiveAction || '',
57
+ timestamp: Date.now()
58
+ })
59
+
33
60
  const more = {} as any
34
- if (patch.correctiveAction) {
35
- more.corrector = user
36
- more.state = DataOocStatus.CORRECTED
61
+
62
+ if (dataOoc.state !== patch.state) {
63
+ if (patch.state === DataOocStatus.CORRECTED) {
64
+ more.corrector = user
65
+ } else {
66
+ more.corrector = null
67
+ }
37
68
  }
38
69
 
39
70
  return await repository.save({
40
71
  ...dataOoc,
41
72
  ...patch,
42
73
  ...more,
74
+ state,
75
+ history,
43
76
  updater: user
44
77
  })
45
78
  }
46
79
 
47
- @Directive('@privilege(category: "data-ooc", privilege: "mutation", domainOwnerGranted: true)')
48
- @Directive('@transaction')
49
- @Mutation(returns => [DataOoc], { description: "To modify multiple DataOoc' information" })
50
- async updateMultipleDataOoc(
51
- @Arg('patches', type => [DataOocPatch]) patches: DataOocPatch[],
52
- @Ctx() context: any
53
- ): Promise<DataOoc[]> {
54
- const { domain, user, tx } = context.state
55
-
56
- let results = []
57
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
58
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
59
- const dataOocRepo = tx.getRepository(DataOoc)
60
-
61
- if (_createRecords.length > 0) {
62
- for (let i = 0; i < _createRecords.length; i++) {
63
- const newRecord = _createRecords[i]
64
-
65
- const result = await dataOocRepo.save({
66
- ...newRecord,
67
- domain,
68
- creator: user,
69
- updater: user
70
- })
71
-
72
- results.push({ ...result, cuFlag: '+' })
73
- }
74
- }
75
-
76
- if (_updateRecords.length > 0) {
77
- for (let i = 0; i < _updateRecords.length; i++) {
78
- const newRecord = _updateRecords[i]
79
- const dataOoc = await dataOocRepo.findOne(newRecord.id)
80
-
81
- const result = await dataOocRepo.save({
82
- ...dataOoc,
83
- ...newRecord,
84
- updater: user
85
- })
86
-
87
- results.push({ ...result, cuFlag: 'M' })
88
- }
89
- }
90
-
91
- return results
92
- }
93
-
94
- @Directive('@privilege(category: "data-ooc", privilege: "mutation", domainOwnerGranted: true)')
95
- @Directive('@transaction')
96
- @Mutation(returns => Boolean, { description: 'To delete DataOoc' })
97
- async deleteDataOoc(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
98
- const { domain, tx } = context.state
99
-
100
- await tx.getRepository(DataOoc).delete({ domain, id })
101
- return true
102
- }
103
-
104
- @Directive('@privilege(category: "data-ooc", privilege: "mutation", domainOwnerGranted: true)')
105
- @Directive('@transaction')
106
- @Mutation(returns => Boolean, { description: 'To delete multiple dataOocs' })
107
- async deleteDataOocs(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
108
- const { domain, tx } = context.state
109
-
110
- await tx.getRepository(DataOoc).delete({
111
- domain,
112
- id: In(ids)
113
- })
114
-
115
- return true
116
- }
80
+ // @Directive('@privilege(category: "data-ooc", privilege: "mutation", domainOwnerGranted: true)')
81
+ // @Directive('@transaction')
82
+ // @Mutation(returns => [DataOoc], { description: "To modify multiple DataOoc' information" })
83
+ // async updateMultipleDataOoc(
84
+ // @Arg('patches', type => [DataOocPatch]) patches: DataOocPatch[],
85
+ // @Ctx() context: any
86
+ // ): Promise<DataOoc[]> {
87
+ // const { domain, user, tx } = context.state
88
+
89
+ // let results = []
90
+ // const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
91
+ // const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
92
+ // const dataOocRepo = tx.getRepository(DataOoc)
93
+
94
+ // if (_createRecords.length > 0) {
95
+ // for (let i = 0; i < _createRecords.length; i++) {
96
+ // const newRecord = _createRecords[i]
97
+
98
+ // const result = await dataOocRepo.save({
99
+ // ...newRecord,
100
+ // domain,
101
+ // creator: user,
102
+ // updater: user
103
+ // })
104
+
105
+ // results.push({ ...result, cuFlag: '+' })
106
+ // }
107
+ // }
108
+
109
+ // if (_updateRecords.length > 0) {
110
+ // for (let i = 0; i < _updateRecords.length; i++) {
111
+ // const newRecord = _updateRecords[i]
112
+ // const dataOoc = await dataOocRepo.findOne(newRecord.id)
113
+
114
+ // const result = await dataOocRepo.save({
115
+ // ...dataOoc,
116
+ // ...newRecord,
117
+ // updater: user
118
+ // })
119
+
120
+ // results.push({ ...result, cuFlag: 'M' })
121
+ // }
122
+ // }
123
+
124
+ // return results
125
+ // }
126
+
127
+ // @Directive('@privilege(category: "data-ooc", privilege: "mutation", domainOwnerGranted: true)')
128
+ // @Directive('@transaction')
129
+ // @Mutation(returns => Boolean, { description: 'To delete DataOoc' })
130
+ // async deleteDataOoc(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
131
+ // const { domain, tx } = context.state
132
+
133
+ // await tx.getRepository(DataOoc).delete({ domain, id })
134
+ // return true
135
+ // }
136
+
137
+ // @Directive('@privilege(category: "data-ooc", privilege: "mutation", domainOwnerGranted: true)')
138
+ // @Directive('@transaction')
139
+ // @Mutation(returns => Boolean, { description: 'To delete multiple dataOocs' })
140
+ // async deleteDataOocs(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
141
+ // const { domain, tx } = context.state
142
+
143
+ // await tx.getRepository(DataOoc).delete({
144
+ // domain,
145
+ // id: In(ids)
146
+ // })
147
+
148
+ // return true
149
+ // }
117
150
  }
@@ -24,10 +24,7 @@ const DATABASE_TYPE = ORMCONFIG.type
24
24
  export enum DataOocStatus {
25
25
  CREATED = 'CREATED',
26
26
  REVIEWED = 'REVIEWED',
27
- CORRECTED = 'CORRECTED',
28
- SUBMITTED = 'SUBMITTED',
29
- APPROVED = 'APPROVED',
30
- REJECTED = 'REJECTED'
27
+ CORRECTED = 'CORRECTED'
31
28
  }
32
29
 
33
30
  registerEnumType(DataOocStatus, {
@@ -113,6 +110,12 @@ export class DataOoc {
113
110
  @Field({ nullable: true })
114
111
  type?: string
115
112
 
113
+ @Column({
114
+ nullable: true
115
+ })
116
+ @Field({ nullable: true })
117
+ useCase?: string
118
+
116
119
  @Column('simple-json', { nullable: true })
117
120
  @Field(type => ScalarObject, { nullable: true })
118
121
  partitionKeys?: ScalarObject
@@ -125,6 +128,10 @@ export class DataOoc {
125
128
  @Field(type => ScalarObject, { nullable: true })
126
129
  spec?: ScalarObject
127
130
 
131
+ @Column('simple-json', { nullable: true })
132
+ @Field(type => ScalarObject, { nullable: true })
133
+ history?: ScalarObject
134
+
128
135
  @Column({
129
136
  nullable: true,
130
137
  type:
@@ -1,4 +1,3 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
1
  import {
3
2
  Column,
4
3
  CreateDateColumn,
@@ -9,12 +8,12 @@ import {
9
8
  RelationId,
10
9
  UpdateDateColumn
11
10
  } from 'typeorm'
12
-
13
- import { User } from '@things-factory/auth-base'
14
- import { config } from '@things-factory/env'
15
11
  import { Domain, ScalarObject } from '@things-factory/shell'
12
+ import { Field, ID, ObjectType } from 'type-graphql'
16
13
 
17
14
  import { DataSet } from '../data-set/data-set'
15
+ import { User } from '@things-factory/auth-base'
16
+ import { config } from '@things-factory/env'
18
17
 
19
18
  const ORMCONFIG = config.get('ormconfig', {})
20
19
  const DATABASE_TYPE = ORMCONFIG.type
@@ -54,6 +53,12 @@ export class DataSample {
54
53
  @Field({ nullable: true })
55
54
  type?: string
56
55
 
56
+ @Column({
57
+ nullable: true
58
+ })
59
+ @Field({ nullable: true })
60
+ useCase?: string
61
+
57
62
  @Column('simple-json', { nullable: true })
58
63
  @Field(type => ScalarObject, { nullable: true })
59
64
  partitionKeys?: ScalarObject
@@ -1,4 +1,6 @@
1
1
  {
2
+ "button.corrected": "corrected",
3
+ "button.reviewed": "reviewed",
2
4
  "field.appliance": "appliance",
3
5
  "field.collected_at": "collected at",
4
6
  "field.corrective-action": "corrective action",
@@ -24,10 +26,13 @@
24
26
  "field.unit": "unit",
25
27
  "field.use-case": "use case",
26
28
  "text.data sample created successfully": "a data sample created successfully",
29
+ "text.data ooc updated successfully": "a data ooc updated successfully",
27
30
  "title.data-entry-form": "data entry form",
28
31
  "title.data-item list": "data item list",
29
32
  "title.data-ooc list": "data OOC list",
33
+ "title.data-ooc view": "data OOC view",
30
34
  "title.data-sample list": "data sample list",
35
+ "title.data-sample view": "data sample view",
31
36
  "title.data-sensor list": "data sensor list",
32
37
  "title.data-set list": "data set list"
33
- }
38
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "button.corrected": "조치완료",
3
+ "button.reviewed": "검토완료",
2
4
  "field.appliance": "어플라이언스",
3
5
  "field.collected_at": "수집일시",
4
6
  "field.corrective-action": "조치 활동",
@@ -24,10 +26,13 @@
24
26
  "field.unit": "단위",
25
27
  "field.use-case": "사용 사례",
26
28
  "text.data sample created successfully": "데이타 샘플이 성공적으로 생성되었습니다",
29
+ "text.data ooc updated successfully": "이탈데이타 내용이 수정되었습니다",
27
30
  "title.data-entry-form": "데이타 입력",
28
31
  "title.data-item list": "데이타 아이템 조회",
29
32
  "title.data-ooc list": "데이타 이탈점 조회",
33
+ "title.data-ooc view": "데이타 이탈점 상세",
30
34
  "title.data-sample list": "데이타 샘플 조회",
35
+ "title.data-sample view": "데이타 샘플 상세",
31
36
  "title.data-sensor list": "데이타 센서 조회",
32
37
  "title.data-set list": "데이타 셋 조회"
33
- }
38
+ }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "button.corrected": "corrected",
3
+ "button.reviewed": "reviewed",
2
4
  "field.appliance": "appliance",
3
5
  "field.collected_at": "collected at",
4
6
  "field.corrective-action": "corrective action",
@@ -24,10 +26,13 @@
24
26
  "field.unit": "unit",
25
27
  "field.use-case": "use case",
26
28
  "text.data sample created successfully": "a data sample created successfully",
29
+ "text.data ooc updated successfully": "a data ooc updated successfully",
27
30
  "title.data-entry-form": "data entry form",
28
31
  "title.data-item list": "data item list",
29
32
  "title.data-ooc list": "data OOC list",
33
+ "title.data-ooc view": "data OOC view",
30
34
  "title.data-sample list": "data sample list",
35
+ "title.data-sample view": "data sample view",
31
36
  "title.data-sensor list": "data sensor list",
32
37
  "title.data-set list": "data set list"
33
38
  }
@@ -1,4 +1,6 @@
1
1
  {
2
+ "button.corrected": "corrected",
3
+ "button.reviewed": "reviewed",
2
4
  "field.appliance": "appliance",
3
5
  "field.collected_at": "collected at",
4
6
  "field.corrective-action": "corrective action",
@@ -24,10 +26,13 @@
24
26
  "field.unit": "unit",
25
27
  "field.use-case": "use case",
26
28
  "text.data sample created successfully": "a data sample created successfully",
29
+ "text.data ooc updated successfully": "a data ooc updated successfully",
27
30
  "title.data-entry-form": "data entry form",
28
31
  "title.data-item list": "data item list",
29
32
  "title.data-ooc list": "data OOC list",
33
+ "title.data-ooc view": "data OOC view",
30
34
  "title.data-sample list": "data sample list",
35
+ "title.data-sample view": "data sample view",
31
36
  "title.data-sensor list": "data sensor list",
32
37
  "title.data-set list": "data set list"
33
38
  }