Skip to content

Commit

Permalink
Update Comments Modal trl
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Apr 29, 2020
1 parent 1b00abc commit 226a6ba
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 21 deletions.
Expand Up @@ -30,24 +30,28 @@

import javax.annotation.Nullable;

/**
* Most likely you want to use {@link CommentEntryId}.
* Please also read the description of {@link CommentEntryRepository}
*/
@Value
public class CommentId implements RepoIdAware
public class CommentEntryParentId implements RepoIdAware
{
int repoId;

@JsonCreator
public static CommentId ofRepoId(final int repoId)
public static CommentEntryParentId ofRepoId(final int repoId)
{
return new CommentId(repoId);
return new CommentEntryParentId(repoId);
}

@Nullable
public static CommentId ofRepoIdOrNull(final int repoId)
public static CommentEntryParentId ofRepoIdOrNull(final int repoId)
{
return repoId > 0 ? ofRepoId(repoId) : null;
}

private CommentId(final int repoId)
private CommentEntryParentId(final int repoId)
{
this.repoId = Check.assumeGreaterThanZero(repoId, "CM_Chat_ID");
}
Expand Down
Expand Up @@ -44,10 +44,12 @@
import java.util.List;

/**
* A Comment is made of an {@link I_CM_Chat} as the parent storing the table and record IDs,
* A CommentEntry is made of an {@link I_CM_Chat} as the parent storing the table and record IDs,
* and an {@link I_CM_ChatEntry} as the children storing the text data of the Comment.
* <p>
* There can be multiple Comments for a record.
* There can be multiple CommentEntries for a PO.
* <p>
* Even though {@link CommentEntryParentId} exists, it has extremely limited purpose. Most likely you want to use {@link CommentEntryId}.
*/
@Repository
public class CommentEntryRepository
Expand All @@ -57,10 +59,10 @@ public class CommentEntryRepository

public void createCommentEntry(final @NonNull String characterData, @NonNull final TableRecordReference tableRecordReference)
{
final CommentId commentId = getOrCreateChat(tableRecordReference);
final CommentEntryParentId commentEntryParentId = getOrCreateParent(tableRecordReference);

final I_CM_ChatEntry chatEntry = InterfaceWrapperHelper.newInstance(I_CM_ChatEntry.class);
chatEntry.setCM_Chat_ID(commentId.getRepoId());
chatEntry.setCM_Chat_ID(commentEntryParentId.getRepoId());
chatEntry.setConfidentialType(X_CM_ChatEntry.CONFIDENTIALTYPE_PublicInformation);
chatEntry.setCharacterData(characterData);
chatEntry.setChatEntryType(X_CM_ChatEntry.CHATENTRYTYPE_NoteFlat);
Expand All @@ -70,25 +72,25 @@ public void createCommentEntry(final @NonNull String characterData, @NonNull fin
@NonNull
public List<CommentEntry> retrieveLastCommentEntries(@NonNull final TableRecordReference tableRecordReference, final int maxNumberOfRecords)
{
final CommentId commentId = getChatIdOrNull(tableRecordReference);
final CommentEntryParentId commentEntryParentId = getParentIdOrNull(tableRecordReference);

if (commentId == null)
if (commentEntryParentId == null)
{
return ImmutableList.of();
}

return queryBL.createQueryBuilder(I_CM_ChatEntry.class)
.addEqualsFilter(I_CM_ChatEntry.COLUMNNAME_CM_Chat_ID, commentId)
.addEqualsFilter(I_CM_ChatEntry.COLUMNNAME_CM_Chat_ID, commentEntryParentId)
.orderByDescending(I_CM_ChatEntry.COLUMNNAME_Created)
.setLimit(maxNumberOfRecords)
.create()
.iterateAndStream()
.map(CommentEntryRepository::toRecordComment)
.map(CommentEntryRepository::toCommentEntry)
.collect(GuavaCollectors.toImmutableList());
}

@NonNull
private static CommentEntry toRecordComment(@NonNull final I_CM_ChatEntry chatEntry)
private static CommentEntry toCommentEntry(@NonNull final I_CM_ChatEntry chatEntry)
{
final UserId createdBy = UserId.ofRepoId(chatEntry.getCreatedBy());
final ZonedDateTime created = TimeUtil.asZonedDateTime(chatEntry.getCreated());
Expand All @@ -104,13 +106,13 @@ private static CommentEntry toRecordComment(@NonNull final I_CM_ChatEntry chatEn
}

@NonNull
private CommentId getOrCreateChat(final @NonNull TableRecordReference tableRecordReference)
private CommentEntryParentId getOrCreateParent(final @NonNull TableRecordReference tableRecordReference)
{
final CommentId commentId = getChatIdOrNull(tableRecordReference);
final CommentEntryParentId commentEntryParentId = getParentIdOrNull(tableRecordReference);

if (commentId != null)
if (commentEntryParentId != null)
{
return commentId;
return commentEntryParentId;
}

final String tableName = tableDAO.retrieveTableName(AdTableId.ofRepoId(tableRecordReference.getAD_Table_ID()));
Expand All @@ -122,17 +124,17 @@ private CommentId getOrCreateChat(final @NonNull TableRecordReference tableRecor
chat.setConfidentialType(X_CM_Chat.CONFIDENTIALTYPE_PublicInformation);
chat.setModerationType(X_CM_Chat.MODERATIONTYPE_NotModerated);
InterfaceWrapperHelper.save(chat);
return CommentId.ofRepoId(chat.getCM_Chat_ID());
return CommentEntryParentId.ofRepoId(chat.getCM_Chat_ID());
}

@Nullable
private CommentId getChatIdOrNull(final @NonNull TableRecordReference tableRecordReference)
private CommentEntryParentId getParentIdOrNull(final @NonNull TableRecordReference tableRecordReference)
{
return queryBL.createQueryBuilder(I_CM_Chat.class)
.addEqualsFilter(I_CM_Chat.COLUMNNAME_AD_Table_ID, tableRecordReference.getAD_Table_ID())
.addEqualsFilter(I_CM_Chat.COLUMNNAME_Record_ID, tableRecordReference.getRecord_ID())
.orderBy(I_CM_Chat.COLUMNNAME_CM_Chat_ID)
.create()
.firstId(CommentId::ofRepoIdOrNull);
.firstId(CommentEntryParentId::ofRepoIdOrNull);
}
}
@@ -0,0 +1,85 @@
-- 2020-04-29T08:04:53.341Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,AD_Org_ID,EntityType) VALUES ('I','Add Comment',0,'Y',TO_TIMESTAMP('2020-04-29 11:04:53','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-04-29 11:04:53','YYYY-MM-DD HH24:MI:SS'),100,544979,'webui.window.comments.add.caption',0,'D')
;

-- 2020-04-29T08:04:53.344Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language, t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y'AND (l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N') AND t.AD_Message_ID=544979 AND NOT EXISTS (SELECT 1 FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;

-- 2020-04-29T08:06:24.780Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,AD_Org_ID,EntityType) VALUES ('I','Created',0,'Y',TO_TIMESTAMP('2020-04-29 11:06:24','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-04-29 11:06:24','YYYY-MM-DD HH24:MI:SS'),100,544980,'webui.window.comments.created.caption',0,'D')
;

-- 2020-04-29T08:06:24.781Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language, t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y'AND (l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N') AND t.AD_Message_ID=544980 AND NOT EXISTS (SELECT 1 FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;

-- 2020-04-29T08:06:29.818Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET MsgText='Erstellt', IsTranslated='Y',Updated=TO_TIMESTAMP('2020-04-29 11:06:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='de_CH' AND AD_Message_ID=544980
;

-- 2020-04-29T08:06:33.945Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET IsTranslated='Y',Updated=TO_TIMESTAMP('2020-04-29 11:06:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='en_US' AND AD_Message_ID=544980
;

-- 2020-04-29T08:06:43.442Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message SET MsgText='Erstellt',Updated=TO_TIMESTAMP('2020-04-29 11:06:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=544980
;

-- 2020-04-29T08:07:21.637Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message SET Value='webui.window.comments.created',Updated=TO_TIMESTAMP('2020-04-29 11:07:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=544980
;

-- 2020-04-29T08:07:44.627Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,AD_Org_ID,EntityType) VALUES ('I','Erstellt durch',0,'Y',TO_TIMESTAMP('2020-04-29 11:07:44','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-04-29 11:07:44','YYYY-MM-DD HH24:MI:SS'),100,544981,'webui.window.comments.createdBy',0,'D')
;

-- 2020-04-29T08:07:44.629Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language, t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y'AND (l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N') AND t.AD_Message_ID=544981 AND NOT EXISTS (SELECT 1 FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;

-- 2020-04-29T08:07:49.566Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET IsTranslated='Y',Updated=TO_TIMESTAMP('2020-04-29 11:07:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='de_CH' AND AD_Message_ID=544981
;

-- 2020-04-29T08:07:57.816Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET MsgText='Created By',Updated=TO_TIMESTAMP('2020-04-29 11:07:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='nl_NL' AND AD_Message_ID=544981
;

-- 2020-04-29T08:08:00.884Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET MsgText='Created By', IsTranslated='Y',Updated=TO_TIMESTAMP('2020-04-29 11:08:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='en_US' AND AD_Message_ID=544981
;

-- 2020-04-29T08:21:40.983Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message SET Value='webui.window.comments.add',Updated=TO_TIMESTAMP('2020-04-29 11:21:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=544979
;

-- 2020-04-29T08:21:44.725Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET MsgText='Kommentar hinzufügen', IsTranslated='Y',Updated=TO_TIMESTAMP('2020-04-29 11:21:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='de_CH' AND AD_Message_ID=544979
;

-- 2020-04-29T08:21:48.546Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message_Trl SET IsTranslated='Y',Updated=TO_TIMESTAMP('2020-04-29 11:21:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Language='en_US' AND AD_Message_ID=544979
;

-- 2020-04-29T08:21:54.066Z
-- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator
UPDATE AD_Message SET MsgText='Kommentar hinzufügen',Updated=TO_TIMESTAMP('2020-04-29 11:21:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=544979
;

0 comments on commit 226a6ba

Please sign in to comment.