Skip to content

Commit 24d9af1

Browse files
IIA-2513 Display Current Year in FQN Section Date Formatting in the Concept Window (#625)
* Update version to start feature: IIa-2513-FQN-Date-Concept-Window * FQN Date and OtherName Date format fix * Added the controller reference in fxml * renamed the snapshot version * Made use of DateTimeUtil constant for Premundane --------- Co-authored-by: Sreehari <bhsreehari@deloitte.com>
1 parent 4132b6c commit 24d9af1

4 files changed

Lines changed: 79 additions & 45 deletions

File tree

framework/src/main/java/dev/ikm/komet/framework/view/ViewMenuTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.function.LongConsumer;
6060

6161
import static dev.ikm.tinkar.common.service.PrimitiveData.PREMUNDANE_TIME;
62+
import static dev.ikm.tinkar.common.util.time.DateTimeUtil.PREMUNDANE;
6263

6364
public class ViewMenuTask extends TrackingCallable<List<MenuItem>> {
6465
private static final Logger LOG = LoggerFactory.getLogger(ViewMenuTask.class);
@@ -199,7 +200,7 @@ private static void addChangePositionMenu(List<MenuItem> menuItems, LongConsumer
199200
Menu aYearMenu = yearMenuMap.getIfAbsentPutWithKey(localTime.getYear(), (int year) -> {
200201
String yearString = Integer.toString(year);
201202
if (time == PREMUNDANE_TIME){
202-
yearString = "Premundane";
203+
yearString = PREMUNDANE;
203204
}
204205
Menu yearMenu = new Menu(yearString);
205206
changePositionMenu.getItems().add(yearMenu);

kview/src/main/java/dev/ikm/komet/kview/mvvm/view/details/DetailsController.java

Lines changed: 70 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@
8585
import org.slf4j.Logger;
8686
import 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.*;
9289
import java.time.format.DateTimeFormatter;
90+
import java.time.format.FormatStyle;
9391
import java.util.*;
9492
import java.util.function.Consumer;
9593
import 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;
9797
import static dev.ikm.tinkar.events.FrameworkTopics.CALCULATOR_CACHE_TOPIC;
9898
import static dev.ikm.tinkar.events.FrameworkTopics.RULES_TOPIC;
9999
import 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("");

kview/src/main/java/dev/ikm/komet/kview/mvvm/view/pattern/PatternDetailsController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel.MODULES_PROPERTY;
5555
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel.PATHS_PROPERTY;
5656
import static dev.ikm.tinkar.common.service.PrimitiveData.PREMUNDANE_TIME;
57+
import static dev.ikm.tinkar.common.util.time.DateTimeUtil.PREMUNDANE;
5758
import static dev.ikm.tinkar.coordinate.stamp.StampFields.MODULE;
5859
import static dev.ikm.tinkar.coordinate.stamp.StampFields.PATH;
5960
import static dev.ikm.tinkar.coordinate.stamp.StampFields.STATUS;
@@ -416,7 +417,7 @@ public void onChanged(Change<? extends DescrName> change) {
416417
ZonedDateTime stampTime = ZonedDateTime.ofInstant(stampInstance, ZoneOffset.UTC);
417418
return DATE_TIME_FORMATTER.format(stampTime);
418419
} else {
419-
return patternViewModel.getPropertyValue(MODE).equals("CREATE")? "" : "Premundane";
420+
return patternViewModel.getPropertyValue(MODE).equals("CREATE")? "" : PREMUNDANE;
420421
}
421422
}));
422423

@@ -461,7 +462,7 @@ public void onChanged(Change<? extends DescrName> change) {
461462
long rawTime = entityVersion.time();
462463
String dateText = null;
463464
if (rawTime == PREMUNDANE_TIME) {
464-
dateText = "Premundane";
465+
dateText = PREMUNDANE;
465466
} else {
466467
Locale userLocale = Locale.getDefault();
467468
LocalDate localDate = Instant.ofEpochMilli(rawTime).atZone(ZoneId.systemDefault()).toLocalDate();
@@ -725,7 +726,7 @@ private List<TextFlow> generateOtherNameRow(DescrName otherName) {
725726
long rawTime = entityVersion.time();
726727
String dateText = null;
727728
if (rawTime == PREMUNDANE_TIME) {
728-
dateText = "Premundane";
729+
dateText = PREMUNDANE;
729730
} else {
730731
Locale userLocale = Locale.getDefault();
731732
LocalDate localDate = Instant.ofEpochMilli(rawTime).atZone(ZoneId.systemDefault()).toLocalDate();
@@ -795,7 +796,7 @@ private Node createFieldEntry(PatternField patternField, int fieldNum) {
795796
} else {
796797
Long fieldMilis = patternField.stamp().time();
797798
if (fieldMilis.equals(PREMUNDANE_TIME)) {
798-
dateAddedStr = "Premundane";
799+
dateAddedStr = PREMUNDANE;
799800
} else {
800801
LocalDate localDate = Instant.ofEpochMilli(fieldMilis).atZone(ZoneId.systemDefault()).toLocalDate();
801802
dateAddedStr = localDate.format(DateTimeFormatter.ofPattern("MMM d, yyyy")).toString();

kview/src/main/resources/dev/ikm/komet/kview/mvvm/view/details/concept-details.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<?import javafx.scene.control.Separator?>
2929
<?import javafx.scene.control.SplitPane?>
3030
<?import javafx.scene.control.SeparatorMenuItem?>
31-
<BorderPane fx:id="detailsOuterBorderPane" stylesheets="@../kview.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1">
31+
<BorderPane fx:id="detailsOuterBorderPane" stylesheets="@../kview.css" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.ikm.komet.kview.mvvm.view.details.DetailsController">
3232
<center>
3333
<BorderPane fx:id="detailsCenterBorderPane">
3434
<top>
@@ -233,7 +233,7 @@
233233

234234
<ResponsiveTextFlow fx:id="fqnDateAddedTextFlow">
235235
<Label styleClass="descr-semantic" />
236-
<Label fx:id="fqnAddDateLabel" styleClass="descr-semantic" text="May 10, 2023" />
236+
<Label fx:id="fqnAddDateLabel" styleClass="grey8-12pt-bold" text="May 10, 2023" />
237237
<Hyperlink text="Attachment" />
238238
<Hyperlink text="Comment" />
239239
</ResponsiveTextFlow>

0 commit comments

Comments
 (0)