Skip to content

Commit

Permalink
fix: Index name with all values.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed May 28, 2024
1 parent 3155b0f commit 92a35b1
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/main/java/org/spin/eca56/util/support/DictionaryDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@
* @author Yamel Senih, [email protected], ERPCyA http://www.erpya.com
*/
public abstract class DictionaryDocument implements IGenericDictionaryDocument {

private int clientId = -1;
private int roleId = -1;
private int userId = -1;
private String language;
private static final String KEY = "new";
private String channel = "none";
private Map<String, Object> document;

public DictionaryDocument() {
withLanguage(Env.getAD_Language(Env.getCtx()));
document = new HashMap<>();
}

@Override
public String getKey() {
return KEY;
}

@Override
public String getChannel() {
return channel;
}

@Override
public Map<String, Object> getValues() {
return document;
}

public void putDocument(Map<String, Object> document) {
// Generic Detail
document.put("language", getLanguage());
Expand All @@ -73,22 +73,22 @@ public void putDocument(Map<String, Object> document) {
document.put("index_value", getIndexValue());
this.document.put("document", document);
}

public DictionaryDocument withClientId(int clientId) {
this.clientId = clientId;
return this;
}

public DictionaryDocument withRoleId(int roleId) {
this.roleId = roleId;
return this;
}

public DictionaryDocument withUserId(int userId) {
this.userId = userId;
return this;
}

public DictionaryDocument withLanguage(String language) {
this.language = language;
return this;
Expand All @@ -109,24 +109,23 @@ public int getUserId() {
public String getLanguage() {
return language;
}

private String getIndexValue() {
StringBuffer channel = new StringBuffer(getChannel());
if(!getLanguage().equals("en_US")) {
channel.append("_").append(getLanguage());
}
if(getClientId() > 0) {

channel.append("_").append(getLanguage());
if(getClientId() >= 0) {
channel.append("_").append(getClientId());
}
if(getRoleId() > 0) {
if(getRoleId() >= 0) {
channel.append("_").append(getRoleId());
}
if(getUserId() > 0) {
if(getUserId() >= 0) {
channel.append("_").append(getUserId());
}
return channel.toString().toLowerCase();
}

public DictionaryDocument withEntity(PO entity) {
channel = entity.get_TableName().toLowerCase();
Map<String, Object> documentDetail = new HashMap<>();
Expand All @@ -136,4 +135,5 @@ public DictionaryDocument withEntity(PO entity) {
putDocument(documentDetail);
return this;
}

}

0 comments on commit 92a35b1

Please sign in to comment.