Skip to content

Commit

Permalink
- WEM: Code Smells
Browse files Browse the repository at this point in the history
  • Loading branch information
alegauss committed Nov 28, 2024
1 parent 9d15e22 commit 880fa83
Show file tree
Hide file tree
Showing 19 changed files with 97 additions and 249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public static URI removeFilterQuery(URI uri, String fq) {
&& nameValuePair.getName().equals(TurSNParamType.FILTER_QUERIES_DEFAULT))) {
resetPaginationOrAddParameter(sbQueryString, nameValuePair.getName(), decodedValue);
}


};
}
return TurCommonsUtils.modifiedURI(uri, sbQueryString);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class TurSNTargetingRules {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,27 @@
*/
package com.viglet.turing.connector.wem.beans;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Setter
public class TurAttrDef {
private String tagName;
@Getter
private String tagName;
private TurMultiValue multiValue;

public TurAttrDef (String tagName, TurMultiValue multiValue) {
this.tagName = tagName;
this.multiValue = multiValue;
}
public String getTagName() {
return tagName;
}

public void setTagName(String tagName) {
this.tagName = tagName;
}

public List<String> getMultiValue() {
public List<String> getMultiValue() {
return multiValue;
}

public void setMultiValue(TurMultiValue multiValue) {
this.multiValue = multiValue;
}

public String toString() {
public String toString() {
return String.format("tagName: %s, multiValue: %s", tagName, multiValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,40 @@
import com.vignette.as.client.exception.ApplicationException;
import com.vignette.as.client.javabean.ContentInstance;
import com.vignette.logging.context.ContextLogger;
import lombok.Getter;
import lombok.Setter;

@Setter
public class TurAttrDefContext {
private static final ContextLogger logger = ContextLogger.getLogger(MethodHandles.lookup().lookupClass());

private ContentInstance contentInstance;
private TuringTag turingTag;
private IHandlerConfiguration iHandlerConfiguration;
private MappingDefinitions mappingDefinitions;
@Getter
private ContentInstance contentInstance;
@Getter
private TuringTag turingTag;
@Getter
private IHandlerConfiguration iHandlerConfiguration;
@Getter
private MappingDefinitions mappingDefinitions;
private AttributeData attributeData;

public TurAttrDefContext(TurAttrDefContext turAttrDefContext) {
this.setAttributeData(turAttrDefContext.getAttributeData());
this.setContentInstance(turAttrDefContext.getContentInstance());
this.setiHandlerConfiguration(turAttrDefContext.getiHandlerConfiguration());
this.setIHandlerConfiguration(turAttrDefContext.getIHandlerConfiguration());
this.setMappingDefinitions(turAttrDefContext.getMappingDefinitions());
this.setTuringTag(turAttrDefContext.getTuringTag());
}

public TurAttrDefContext(ContentInstance contentInstance, TuringTag turingTag,
IHandlerConfiguration iHandlerConfiguration, MappingDefinitions mappingDefinitions) {
this.setContentInstance(contentInstance);
this.setiHandlerConfiguration(iHandlerConfiguration);
this.setIHandlerConfiguration(iHandlerConfiguration);
this.setMappingDefinitions(mappingDefinitions);
this.setTuringTag(turingTag);
}

public ContentInstance getContentInstance() {
return contentInstance;
}

public void setContentInstance(ContentInstance contentInstance) {
this.contentInstance = contentInstance;
}

public TuringTag getTuringTag() {
return turingTag;
}

public void setTuringTag(TuringTag turingTag) {
this.turingTag = turingTag;
}

public IHandlerConfiguration getiHandlerConfiguration() {
return iHandlerConfiguration;
}

public void setiHandlerConfiguration(IHandlerConfiguration iHandlerConfiguration) {
this.iHandlerConfiguration = iHandlerConfiguration;
}

public MappingDefinitions getMappingDefinitions() {
return mappingDefinitions;
}

public void setMappingDefinitions(MappingDefinitions mappingDefinitions) {
this.mappingDefinitions = mappingDefinitions;
}

public AttributeData getAttributeData() {
public AttributeData getAttributeData() {
if (attributeData != null)
return attributeData;

Expand All @@ -96,7 +71,4 @@ public AttributeData getAttributeData() {
return null;
}

public void setAttributeData(AttributeData attributeData) {
this.attributeData = attributeData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static TurMultiValue singleItem(String text) {

public static TurMultiValue fromList(List<String> list) {
TurMultiValue turMultiValue = new TurMultiValue();
list.forEach(turMultiValue::add);
turMultiValue.addAll(list);
return turMultiValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@
*/
package com.viglet.turing.connector.wem.beans;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Setter
public class TuringTag {
private String tagName;
private List<String> srcAttributeRelation;
private String srcAttributeType;
private String srcXmlName;
private String srcClassName;
@Getter
private String tagName;
@Getter
private List<String> srcAttributeRelation;
@Getter
private String srcAttributeType;
@Getter
private String srcXmlName;
@Getter
private String srcClassName;
private boolean srcMandatory;
private boolean srcUniqueValues;
private String textValue;
@Getter
private String textValue;

@Override
public String toString() {
Expand All @@ -41,63 +51,11 @@ public TuringTag() {
super();
}

public String getSrcAttributeType() {
return srcAttributeType;
}

public List<String> getSrcAttributeRelation() {
return srcAttributeRelation;
}

public String getSrcClassName() {
return srcClassName;
}

public boolean getSrcMandatory() {
public boolean getSrcMandatory() {
return srcMandatory;
}

public String getTagName() {
return tagName;
}

public String getTextValue() {
return textValue;
}

public void setSrcAttributeType(String srcAttributeType) {
this.srcAttributeType = srcAttributeType;
}

public void setSrcAttributeRelation(List<String> srcAttributeRelation) {
this.srcAttributeRelation = srcAttributeRelation;
}

public void setSrcClassName(String srcClassName) {
this.srcClassName = srcClassName;
}

public void setSrcMandatory(boolean srcMandatory) {
this.srcMandatory = srcMandatory;
}

public void setTagName(String tagName) {
this.tagName = tagName;
}

public String getSrcXmlName() {
return srcXmlName;
}

public void setSrcXmlName(String srcXmlName) {
this.srcXmlName = srcXmlName;
}

public void setTextValue(String textValue) {
this.textValue = textValue;
}

@Override
@Override
public boolean equals(Object obj) {
if (obj instanceof TuringTag) {
return this.getTagName().equals(((TuringTag) obj).getTagName());
Expand All @@ -115,7 +73,4 @@ public boolean isSrcUniqueValues() {
return srcUniqueValues;
}

public void setSrcUniqueValues(boolean srcUniqueValues) {
this.srcUniqueValues = srcUniqueValues;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.HashMap;

//HashMap <String tag, ArrayList<TuringTag> turingTags>
public class TuringTagMap extends HashMap<String, ArrayList<TuringTag>>{

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static List<TurAttrDef> attributeByClass(TurAttrDefContext turAttrDefCont

TuringTag turingTag = turAttrDefContext.getTuringTag();
ContentInstance ci = turAttrDefContext.getContentInstance();
IHandlerConfiguration config = turAttrDefContext.getiHandlerConfiguration();
IHandlerConfiguration config = turAttrDefContext.getIHandlerConfiguration();
List<TurAttrDef> attributesDefs = new ArrayList<>();

if (turingTag.getSrcClassName() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static List<TurAttrDef> attributeXMLUpdate(TurAttrDefContext turAttrDefCo
log.debug(String.format("%s = %s", turingTag.getTagName(), attributeData.getValue().toString()));

if (attributeData != null && attributeData.getValue().toString() != null
&& attributeData.getValue().toString().trim().length() > 0)
&& !attributeData.getValue().toString().trim().isEmpty())
return TurWEMAttrWidget.attributeByWidget(turAttrDefContext, attributeData);

return new ArrayList<>();
Expand Down Expand Up @@ -105,7 +105,7 @@ private static void addRelationAttributes(TurAttrDefContext turAttrDefContext, S
AttributeData attributeData = attributedObject.getAttribute(attributeName);
if (log.isDebugEnabled())
log.debug(String.format("Attribute: %s, Value: %s", attributeName, attributeValue));
if (attributeValue != null && attributeValue.trim().length() > 0)
if (attributeValue != null && !attributeValue.trim().isEmpty())
attributesDefs.addAll(attributeXMLUpdate(turAttrDefContext, attributeData));
}
}
Expand All @@ -117,7 +117,7 @@ private static List<TurAttrDef> addAttributeWithoutRelator(TurAttrDefContext tur
ContentInstance ci = turAttrDefContext.getContentInstance();
String attributeName = turAttrDefContext.getTuringTag().getSrcXmlName();
if (ci.getAttributeValue(attributeName) != null
&& ci.getAttributeValue(attributeName).toString().trim().length() > 0) {
&& !ci.getAttributeValue(attributeName).toString().trim().isEmpty()) {
AttributeData attributeData = ci.getAttribute(attributeName);
return attributeXMLUpdate(turAttrDefContext, attributeData);
} else if (turingTag.getSrcClassName() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static AttributedObject[] detectAttributesFromRelator(List<String> relat
List<AttributedObject[]> nestedRelationChild = new ArrayList<>();
for (AttributedObject[] attributesFromRelation : currentRelation) {

for (AttributedObject attributeFromRelation : Arrays.asList(attributesFromRelation)) {
for (AttributedObject attributeFromRelation : attributesFromRelation) {
try {
AttributedObject[] childRelation = attributeFromRelation
.getRelations(relationTag.get(nextPosition));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static List<TurAttrDef> attributeFileWidgetUpdate(TurAttrDefContext turAt

TuringTag turingTag = turAttrDefContext.getTuringTag();
ContentInstance ci = turAttrDefContext.getContentInstance();
IHandlerConfiguration config = turAttrDefContext.getiHandlerConfiguration();
IHandlerConfiguration config = turAttrDefContext.getIHandlerConfiguration();

if (log.isDebugEnabled()) {
log.debug("TurWEMUpdateFileWidget started");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.vignette.logging.context.ContextLogger;
import com.vignette.util.CustomerMsg;
import com.vignette.util.MsgObject;
import lombok.Setter;

import java.io.IOException;
import java.io.StringReader;
Expand All @@ -49,6 +50,7 @@ public class GenericResourceHandlerConfiguration implements IHandlerConfiguratio
private static final String DEFAULT_SN_LOCALE = "en_US";
private static final String DEFAULT_DPS_CONTEXT = "sites";

@Setter
private String turingURL;
private String snSite;
private String snLocale;
Expand All @@ -57,7 +59,9 @@ public class GenericResourceHandlerConfiguration implements IHandlerConfiguratio
private String cdaURLPrefix;
private String sitesAssociationPriority;
private String fileSourcePath;
@Setter
private String login;
@Setter
private String password;
private String providerName;
private static final ContextLogger log = ContextLogger.getLogger(MethodHandles.lookup().lookupClass());
Expand All @@ -72,10 +76,6 @@ public String getTuringURL() {
return turingURL;
}

public void setTuringURL(String turingURL) {
this.turingURL = turingURL;
}

@Override
public String getMappingsXML() {
return mappingsXML;
Expand Down Expand Up @@ -286,19 +286,11 @@ public String getLogin() {
return login;
}

public void setLogin(String login) {
this.login = login;
}

@Override
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

@Override
public String getProviderName() {
return providerName;
Expand Down
Loading

0 comments on commit 880fa83

Please sign in to comment.