Skip to content

Commit af000ae

Browse files
committed
add Plm File meta-data: date created, last update, user created, user last updated
1 parent 57b12fe commit af000ae

File tree

3 files changed

+65
-8
lines changed

3 files changed

+65
-8
lines changed

grails-app/domain/plm/PlmFreeCadPart.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class PlmFreeCadPart implements IDomainHistory<PlmFreeCadPart> {
4343

4444
User lockedBy
4545

46+
Date plmFileDateCreated
47+
Date plmFileLastUpdated
48+
String plmFileUserUpdated
49+
String plmFileUserCreated
4650
String plmFilePath
4751
String plmContentType
4852
String plmContentShaOne
@@ -66,6 +70,8 @@ class PlmFreeCadPart implements IDomainHistory<PlmFreeCadPart> {
6670

6771
static constraints = {
6872
lockedBy nullable: true
73+
plmFileLastUpdated nullable: true
74+
plmFileUserCreated nullable: true
6975
comment nullable: true
7076
commentVersion nullable: true, widget: "markdown"
7177
nextVersion nullable: true
@@ -106,6 +112,10 @@ class PlmFreeCadPart implements IDomainHistory<PlmFreeCadPart> {
106112
oldPart.active = false
107113
oldPart.nextVersion = this
108114
oldPart.lockedBy = lockedBy
115+
oldPart.plmFileDateCreated = plmFileDateCreated
116+
oldPart.plmFileLastUpdated = plmFileLastUpdated
117+
oldPart.plmFileUserUpdated = plmFileUserUpdated
118+
oldPart.plmFileUserCreated = plmFileUserCreated
109119
oldPart.plmFilePath = plmFilePath
110120
oldPart.plmContentType = plmContentType
111121
oldPart.plmContentShaOne = plmContentShaOne

grails-app/i18n/messages.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ default.userCreated.username.label=User Created
2828
plmFreeCadLink.linkClaimChild.label=Claim Child
2929
plmFreeCadLink.linkTransform.label=Transform
3030
plmFreeCadLink.linkCopyOnChange.label=Copy On Change
31-
plmFreeCadPart.status.label=Status
31+
plmFreeCadPart.status.label=Status
32+
plmFreeCadPart.plmFileUserCreated.label=File User Created
33+
plmFreeCadPart.plmFileDateCreated.label=File Date Created(UTC)
34+
plmFreeCadPart.plmFileUserUpdated.label=File User Updated
35+
plmFreeCadPart.plmFileLastUpdated.label=File Date Updated(UTC)

grails-app/services/plm/PlmFreeCadUiService.groovy

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import javax.annotation.PostConstruct
2929
import java.nio.file.Files
3030
import java.nio.file.Path
3131
import java.security.MessageDigest
32+
import java.text.SimpleDateFormat
3233
import java.util.zip.ZipEntry
3334
import java.util.zip.ZipException
3435
import java.util.zip.ZipOutputStream
@@ -92,6 +93,12 @@ class PlmFreeCadUiService implements WebAttributes {
9293
section 'Links', {
9394
filterField p.plmLinks_, l.part_, p.originalName_
9495
}
96+
section 'Plm File', {
97+
filterField p.plmFileUserCreated_
98+
filterField p.plmFileDateCreated_
99+
filterField p.plmFileUserUpdated_
100+
filterField p.plmFileLastUpdated_
101+
}
95102
}
96103
}
97104

@@ -168,6 +175,14 @@ class PlmFreeCadUiService implements WebAttributes {
168175
sortableFieldHeader p.userUpdated_, u.username_
169176
d = sortableFieldHeader ColumnHeaderFieldSpec.DefaultSortingDirection.DESC, p.lastUpdated_
170177
}
178+
column {
179+
sortableFieldHeader p.plmFileUserCreated_
180+
sortableFieldHeader p.plmFileDateCreated_
181+
}
182+
column {
183+
sortableFieldHeader p.plmFileUserUpdated_
184+
sortableFieldHeader p.plmFileLastUpdated_
185+
}
171186
column {
172187
sortableFieldHeader p.lockedBy_, u.username_
173188
sortableFieldHeader p.commentVersion_
@@ -176,7 +191,6 @@ class PlmFreeCadUiService implements WebAttributes {
176191
sortableFieldHeader p.originalName_
177192
sortableFieldHeader p.status_
178193
}
179-
fieldHeader 'Comment'
180194
}
181195
def f = new UiFilterSpecifier().ui PlmFreeCadPart, {
182196
filterFieldExpressionBool(null, new FilterExpression(p.nextVersion_, Operator.EQ, null), true)
@@ -195,6 +209,14 @@ class PlmFreeCadUiService implements WebAttributes {
195209
rowField obj.lastUpdated
196210
rowField obj.userUpdated?.username
197211
}
212+
rowColumn {
213+
rowField obj.plmFileUserCreated
214+
rowField obj.plmFileDateCreated.format('yyyy-MM-dd hh:mm:ss')
215+
}
216+
rowColumn {
217+
rowField obj.plmFileUserUpdated
218+
rowField obj.plmFileLastUpdated.format('yyyy-MM-dd hh:mm:ss')
219+
}
198220
rowColumn {
199221
rowField obj.lockedBy?.username
200222
rowField obj.commentVersion
@@ -205,9 +227,6 @@ class PlmFreeCadUiService implements WebAttributes {
205227
rowField obj.originalName, Style.BLUE
206228
rowField obj.status_
207229
}
208-
rowColumn {
209-
rowField obj.comment
210-
}
211230
}
212231
}
213232
}
@@ -223,6 +242,11 @@ class PlmFreeCadUiService implements WebAttributes {
223242
fieldLabeled part.userUpdated_
224243
fieldLabeled part.originalName_
225244
fieldLabeled part.plmContentType_
245+
fieldLabeled part.plmFileLastUpdated_
246+
fieldLabeled part.plmFileUserUpdated_
247+
fieldLabeled part.plmFileDateCreated_
248+
fieldLabeled part.plmFileUserCreated_
249+
fieldLabeled part.plmContentType_
226250
field "Status", part.status_, Style.EMPHASIS
227251
fieldLabeled part.lockedBy_
228252
}
@@ -258,9 +282,17 @@ class PlmFreeCadUiService implements WebAttributes {
258282
if (h)
259283
for (def i : h) {
260284
rowGroupHeader "${i.historyUserCreated} on ${i.historyDateCreated}"
261-
if (i.commentVersion && !p) row {
262-
rowColumn {
263-
rowField Markdown.getContentHtml(i.commentVersion), Style.MARKDOWN_BODY
285+
if (i.commentVersion && !p) {
286+
row {
287+
rowColumn {
288+
rowField Markdown.getContentHtml(i.commentVersion), Style.MARKDOWN_BODY
289+
}
290+
}
291+
} else if (!p) {
292+
row {
293+
rowColumn {
294+
rowField 'Initial version'
295+
}
264296
}
265297
}
266298
if (p) {
@@ -279,6 +311,10 @@ class PlmFreeCadUiService implements WebAttributes {
279311
if (p.status != i.status) diff << "<li>Status became from ${p.status} to <b>${i.status}</b></li>"
280312
if (p.originalName != i.originalName) diff << "<li>Original Name became from ${p.originalName} to <b>${i.originalName}</b></li>"
281313
if (p.plmContentType != i.plmContentType) diff << "<li>Content Type became from ${p.plmContentType} to <b>${i.plmContentType}</b></li>"
314+
if (p.plmFileLastUpdated != i.plmFileLastUpdated) diff << "<li>Declared updated date became from ${p.plmFileLastUpdated} to <b>${i.plmFileLastUpdated}</b></li>"
315+
if (p.plmFileDateCreated != i.plmFileDateCreated) diff << "<li>Declared creation Date became from ${p.plmFileDateCreated} to <b>${i.plmFileDateCreated}</b></li>"
316+
if (p.plmFileUserCreated != i.plmFileUserCreated) diff << "<li>Declared user created became from ${p.plmFileUserCreated} to <b>${i.plmFileUserCreated}</b></li>"
317+
if (p.plmFileUserUpdated != i.plmFileUserUpdated) diff << "<li>Declared user updated became from ${p.plmFileUserUpdated} to <b>${i.plmFileUserUpdated}</b></li>"
282318
if (p.comment != i.comment) diff << "<li>Comment became from ${p.comment} to <b>${i.comment}</b></li>"
283319
if (p.plmLinks*.part.id.sort() != i.plmLinks*.part.id.sort()) diff << "<li>Links became from [${p.plmLinks*.part.originalName.join(', ')}] to [${i.plmLinks*.part.originalName.join(', ')}]"
284320
diff << "</ul>"
@@ -311,6 +347,8 @@ class PlmFreeCadUiService implements WebAttributes {
311347
def r = FreecadPlm.Bucket.newBuilder()
312348
Map<String, PlmFreeCadPart> loToP = [:]
313349
Map<String, List<PlmFreeCadPart>> pToLo = [:]
350+
def dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
351+
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
314352
d.each {
315353
def f = it.value
316354
def c = f.fileContent.toByteArray()
@@ -342,6 +380,11 @@ class PlmFreeCadUiService implements WebAttributes {
342380
pp.fileId = f.id
343381
pp.comment = f.comment
344382
pp.label = f.label
383+
pp.plmFileLastUpdated = dateFormat.parse(f.lastModifiedDate)
384+
pp.plmFileDateCreated = dateFormat.parse(f.createdDate)
385+
pp.plmFileUserCreated = f.createdBy
386+
pp.plmFileUserUpdated = f.lastModifiedBy
387+
pp.label = f.label
345388
pp.plmContentType = Files.probeContentType(file.toPath())
346389
pp.plmContentShaOne = sha1
347390
pp.originalName = f.name

0 commit comments

Comments
 (0)