8585import org .slf4j .Logger ;
8686import org .slf4j .LoggerFactory ;
8787
88- import java .time .Instant ;
89- import java .time .ZoneId ;
90- import java .time .ZoneOffset ;
91- import java .time .ZonedDateTime ;
88+ import java .time .*;
9289import java .time .format .DateTimeFormatter ;
90+ import java .time .format .FormatStyle ;
9391import java .util .*;
9492import java .util .function .Consumer ;
9593import java .util .stream .Collectors ;
9694
95+ import static dev .ikm .tinkar .common .service .PrimitiveData .PREMUNDANE_TIME ;
96+ import static dev .ikm .tinkar .common .util .time .DateTimeUtil .PREMUNDANE ;
9797import static dev .ikm .tinkar .events .FrameworkTopics .CALCULATOR_CACHE_TOPIC ;
9898import static dev .ikm .tinkar .events .FrameworkTopics .RULES_TOPIC ;
9999import static dev .ikm .komet .kview .fxutils .IconsHelper .IconType .ATTACHMENT ;
@@ -1033,14 +1033,8 @@ public void updateConceptDescription() {
10331033 */
10341034 private VBox generateOtherNameRow (SemanticEntityVersion semanticEntityVersion , List <String > fieldDescriptions ) {
10351035 VBox textFlowsBox = new VBox ();
1036- DateTimeFormatter DATE_TIME_FORMATTER = dateFormatter ("MMM dd, yyyy" );
1037-
10381036 String descrSemanticStr = String .join (", " , fieldDescriptions );
10391037
1040- // update date
1041- Instant stampInstance = Instant .ofEpochSecond (semanticEntityVersion .stamp ().time ()/1000 );
1042- String time = DATE_TIME_FORMATTER .format (stampInstance );
1043-
10441038 // create textflow to hold regular name label
10451039 TextFlow row1 = new TextFlow ();
10461040 String otherNameDescText = getFieldValueByMeaning (semanticEntityVersion , TinkarTerm .TEXT_FOR_DESCRIPTION );
@@ -1064,26 +1058,43 @@ private VBox generateOtherNameRow(SemanticEntityVersion semanticEntityVersion, L
10641058
10651059 TextFlow row2 = new TextFlow ();
10661060 Text dateAddedLabel = new Text ("Date Added: " );
1067- dateAddedLabel .getStyleClass ().add ("descr-semantic" );
1068- Text dateLabel = new Text (time );
1069- dateLabel .getStyleClass ().add ("descr-semantic" );
1061+ dateAddedLabel .getStyleClass ().add ("grey8-12pt-bold" );
10701062
1071- Region spacer = new Region ();
1072- spacer .setMinWidth (10 );
1063+ if (semanticEntityVersion .publicId () != null ) {
1064+ ViewCalculator viewCalculator = conceptViewModel .getViewProperties ().calculator ();
1065+ Latest <EntityVersion > semanticVersionLatest = viewCalculator .latest (Entity .nid (semanticEntityVersion .publicId ()));
1066+ semanticVersionLatest .ifPresent (entityVersion -> {
1067+ long rawTime = entityVersion .time ();
1068+ String dateText = null ;
1069+ if (rawTime == PREMUNDANE_TIME ) {
1070+ dateText = PREMUNDANE ;
1071+ } else {
1072+ Locale userLocale = Locale .getDefault ();
1073+ LocalDate localDate = Instant .ofEpochMilli (rawTime ).atZone (ZoneId .systemDefault ()).toLocalDate ();
1074+ DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDate (FormatStyle .MEDIUM ).withLocale (userLocale );
1075+ dateText = formatter .format (localDate );
1076+ }
10731077
1074- Hyperlink attachmentHyperlink = createActionLink ( IconsHelper . createIcon ( ATTACHMENT ) );
1075- Hyperlink commentsHyperlink = createActionLink ( IconsHelper . createIcon ( COMMENTS ) );
1078+ Text dateLabel = new Text ( dateText );
1079+ dateLabel . getStyleClass (). add ( "grey8-12pt-bold" );
10761080
1077- // Add the date info and additional hyperlinks
1078- row2 .getChildren ().addAll (dateAddedLabel , dateLabel , spacer , attachmentHyperlink , commentsHyperlink );
1081+ Region spacer = new Region ();
1082+ spacer .setMinWidth (10 );
1083+
1084+ Hyperlink attachmentHyperlink = createActionLink (IconsHelper .createIcon (ATTACHMENT ));
1085+ Hyperlink commentsHyperlink = createActionLink (IconsHelper .createIcon (COMMENTS ));
1086+
1087+ // Add the date info and additional hyperlinks
1088+ row2 .getChildren ().addAll (dateAddedLabel , dateLabel , spacer , attachmentHyperlink , commentsHyperlink );
1089+ });
1090+ }
10791091
10801092 textFlowsBox .getChildren ().addAll (row1 , row2 );
10811093 return textFlowsBox ;
10821094 }
10831095
10841096 private VBox generateOtherNameRow (DescrName otherName ) {
10851097 VBox textFlowsBox = new VBox ();
1086- DateTimeFormatter DATE_TIME_FORMATTER = dateFormatter ("MMM dd, yyyy" );
10871098 ViewCalculator viewCalculator = conceptViewModel .getViewProperties ().calculator ();
10881099 ConceptEntity caseSigConcept = otherName .getCaseSignificance ();
10891100 String casSigText = viewCalculator .getRegularDescriptionText (caseSigConcept .nid ())
@@ -1095,11 +1106,6 @@ private VBox generateOtherNameRow(DescrName otherName) {
10951106
10961107 String descrSemanticStr = "%s, %s" .formatted (casSigText , langText );
10971108
1098- // update date
1099- long epochmillis = getStampViewModel () == null ? System .currentTimeMillis () : getStampViewModel ().getValue (TIME );
1100- Instant stampInstance = Instant .ofEpochSecond (epochmillis /1000 );
1101- String time = DATE_TIME_FORMATTER .format (stampInstance );
1102-
11031109 // create textflow to hold regular name label
11041110 TextFlow row1 = new TextFlow ();
11051111
@@ -1136,19 +1142,35 @@ private VBox generateOtherNameRow(DescrName otherName) {
11361142
11371143 TextFlow row2 = new TextFlow ();
11381144 Text dateAddedLabel = new Text ("Date Added: " );
1139- dateAddedLabel .getStyleClass ().add ("descr-semantic" );
1140- Text dateLabel = new Text (time );
1141- dateLabel .getStyleClass ().add ("descr-semantic" );
1145+ dateAddedLabel .getStyleClass ().add ("grey8-12pt-bold" );
1146+
1147+ if (otherName .getSemanticPublicId () != null ) {
1148+ Latest <EntityVersion > semanticVersionLatest = viewCalculator .latest (Entity .nid (otherName .getSemanticPublicId ()));
1149+ semanticVersionLatest .ifPresent (entityVersion -> {
1150+ long rawTime = entityVersion .time ();
1151+ String dateText = null ;
1152+ if (rawTime == PREMUNDANE_TIME ) {
1153+ dateText = PREMUNDANE ;
1154+ } else {
1155+ Locale userLocale = Locale .getDefault ();
1156+ LocalDate localDate = Instant .ofEpochMilli (rawTime ).atZone (ZoneId .systemDefault ()).toLocalDate ();
1157+ DateTimeFormatter formatter = DateTimeFormatter .ofLocalizedDate (FormatStyle .MEDIUM ).withLocale (userLocale );
1158+ dateText = formatter .format (localDate );
1159+ }
11421160
1143- Region spacer = new Region ( );
1144- spacer . setMinWidth ( 10 );
1161+ Text dateLabel = new Text ( dateText );
1162+ dateLabel . getStyleClass (). add ( "grey8-12pt-bold" );
11451163
1146- Hyperlink attachmentHyperlink = createActionLink ( IconsHelper . createIcon ( ATTACHMENT ) );
1147- Hyperlink commentsHyperlink = createActionLink ( IconsHelper . createIcon ( COMMENTS ) );
1164+ Region spacer = new Region ( );
1165+ spacer . setMinWidth ( 10 );
11481166
1149- // Add the date info and additional hyperlinks
1150- row2 . getChildren (). addAll ( dateAddedLabel , dateLabel , spacer , attachmentHyperlink , commentsHyperlink );
1167+ Hyperlink attachmentHyperlink = createActionLink ( IconsHelper . createIcon ( ATTACHMENT ));
1168+ Hyperlink commentsHyperlink = createActionLink ( IconsHelper . createIcon ( COMMENTS ) );
11511169
1170+ // Add the date info and additional hyperlinks
1171+ row2 .getChildren ().addAll (dateAddedLabel , dateLabel , spacer , attachmentHyperlink , commentsHyperlink );
1172+ });
1173+ }
11521174 textFlowsBox .getChildren ().addAll (row1 , row2 );
11531175 return textFlowsBox ;
11541176 }
@@ -1174,10 +1196,19 @@ private void updateFQNSemantics(SemanticEntityVersion semanticEntityVersion, Lis
11741196 fqnContainer .getChildren ().setAll (latestFqnText , fqnDescriptionSemanticText );
11751197
11761198 // update date
1177- Instant stampInstance = Instant .ofEpochSecond (semanticEntityVersion .stamp ().time ()/1000 );
1178- ZonedDateTime stampTime = ZonedDateTime .ofInstant (stampInstance , ZoneOffset .UTC );
1179- String time = DATE_TIME_FORMATTER .format (stampTime );
1180- fqnAddDateLabel .setText ("Date Added: " + time );
1199+ String dateAddedStr = "" ;
1200+ if (semanticEntityVersion .stamp () == null ) {
1201+ dateAddedStr = LocalDate .now ().format (DateTimeFormatter .ofPattern ("MMM d, yyyy" )).toString ();
1202+ } else {
1203+ Long fieldMilis = semanticEntityVersion .stamp ().time ();
1204+ if (fieldMilis .equals (PREMUNDANE_TIME )) {
1205+ dateAddedStr = PREMUNDANE ;
1206+ } else {
1207+ LocalDate localDate = Instant .ofEpochMilli (fieldMilis ).atZone (ZoneId .systemDefault ()).toLocalDate ();
1208+ dateAddedStr = localDate .format (DateTimeFormatter .ofPattern ("MMM d, yyyy" )).toString ();
1209+ }
1210+ }
1211+ fqnAddDateLabel .setText ("Date Added: " + dateAddedStr );
11811212
11821213 Region spacer = new Region ();
11831214 spacer .setMinWidth (10 );
@@ -1351,6 +1382,7 @@ public void clearView() {
13511382 definitionTextField .clear ();
13521383 identifierControl .setPublicId ("" );
13531384 lastUpdatedLabel .setText ("" );
1385+ fqnAddDateLabel .setText ("" );
13541386 moduleLabel .setText ("" );
13551387 pathLabel .setText ("" );
13561388 statusLabel .setText ("" );
0 commit comments