Skip to content

Commit

Permalink
Removing useless attributes (es attributes migration)
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Oct 25, 2024
1 parent 5456f06 commit e13b609
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,51 +298,12 @@ private Product translate(Product p) {

// Attributes migration
// Purging aggregated
p.getAttributes().getAggregatedAttributes().clear();

p.getAttributes().getUnmapedAttributes().forEach(e-> {
p.getAttributes().getAll().put(e.getName(), e);

e.getSources().forEach(s -> {
SourcedAttribute sa = new SourcedAttribute();
sa.setDataSourcename(s.getKey());
sa.setValue(s.getValue());
e.addSourceAttribute(sa);

});
e.getSources().clear();

});

p.getAttributes().getUnmapedAttributes().clear();



// Brands

p.getAlternativeBrands().forEach(b -> {

if (!b.getKey().equalsIgnoreCase(b.getValue())) {
p.getAkaBrands().put(b.getKey(), b.getValue().toUpperCase());
}
});


// Models
p.setAkaModels(p.getAlternativeModels());



p.getAttributes().setAggregatedAttributes(null);
p.getAttributes().setUnmapedAttributes(null);
p.setAlternativeBrands(null);
p.setAlternativeModels(null);

try {
aggregationService.sanitize(p);
} catch (AggregationSkipException e) {
logger.error("Error in import, with product sanitisation",e);
}
//
// try {
// aggregationService.sanitize(p);
// } catch (AggregationSkipException e) {
// logger.error("Error in import, with product sanitisation",e);
// }


// Setting datasources to new Map format
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.open4goods.commons.model.data.AiDescriptions;
import org.open4goods.commons.model.data.Resource;
import org.open4goods.commons.model.data.Score;
import org.open4goods.commons.model.data.UnindexedKeyValTimestamp;
import org.open4goods.commons.services.StandardiserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -95,18 +94,11 @@ public class Product implements Standardisable {
/** If true, means the item is excluded from vertical representation (because not enough data, ....)**/
private boolean excluded = false;

/** The list of other model's known for this product **/
// TODO(p1) : remove once migration
private Set<String> alternativeModels = new HashSet<>();

/** The list of other model's known for this product **/
private Set<String> akaModels = new HashSet<>();


/** The list of other id's known for this product **/
// TODO(p1, design) : Remove once migration
private Set<UnindexedKeyValTimestamp> alternativeBrands = new HashSet<>();

private Map<String,String> akaBrands = new HashMap<String, String>();


Expand Down Expand Up @@ -668,15 +660,6 @@ public String shortestModel() {




public Set<UnindexedKeyValTimestamp> getAlternativeBrands() {
return alternativeBrands;
}
public void setAlternativeBrands(Set<UnindexedKeyValTimestamp> alternativeBrands) {
this.alternativeBrands = alternativeBrands;
}


public Long getId() {
return id;
}
Expand Down Expand Up @@ -818,14 +801,6 @@ public void setCoverImagePath(String coverImagePath) {
this.coverImagePath = coverImagePath;
}

public Set<String> getAlternativeModels() {
return alternativeModels;
}

public void setAlternativeModels(Set<String> alternativeModels) {
this.alternativeModels = alternativeModels;
}

public boolean isExcluded() {
return excluded;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package org.open4goods.commons.model.product;

import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.open4goods.commons.model.data.UnindexedKeyValTimestamp;

public class ProductAttribute extends SourcableAttribute implements IAttribute {

Expand All @@ -29,13 +21,6 @@ public class ProductAttribute extends SourcableAttribute implements IAttribute {
// TODO(p1, design) : remove after migration
private Double numericValue;

/**
* The collections of conflicts for this attribute
* */
// TODO(p1, design) : remove after migration
private Set<UnindexedKeyValTimestamp> sources = new HashSet<>();



/**
* The attribute raw rawValue
Expand Down Expand Up @@ -155,14 +140,6 @@ public void setIcecatTaxonomyIds(Set<Integer> icecatTaxonomyIds) {
this.icecatTaxonomyIds = icecatTaxonomyIds;
}

public Set<UnindexedKeyValTimestamp> getSources() {
return sources;
}

public void setSources(Set<UnindexedKeyValTimestamp> sources) {
this.sources = sources;
}

public Set<SourcedAttribute> getSource() {
return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,9 @@ public class ProductAttributes {
*/
private Map<ReferentielKey, String> referentielAttributes = new HashMap<>();

//TODO(p1,design): remove when migration done
private Map<String,ProductAttribute> aggregatedAttributes = new HashMap<>();

private Map<String,IndexedAttribute> indexed = new HashMap<>();


//TODO(p1,design): remove when migration done

private Set<ProductAttribute> unmapedAttributes = new HashSet<>();


private Map<String, ProductAttribute> all = new HashMap<>();

@Transient
Expand Down Expand Up @@ -74,7 +66,6 @@ public String toString() {
return "ref:"+referentielAttributes.size()+ " , indexed:"+indexed.size() +" , all:"+all.size();
}



public int count() {

Expand Down Expand Up @@ -114,16 +105,6 @@ public Map<String, String> referentielAttributesAsStringKeys() {
));
}




// public Set<AggregatedFeature> getFeatures() {
// return features;
// }
//
// public void setFeatures(Set<AggregatedFeature> features) {
// this.features = features;
// }



Expand Down Expand Up @@ -158,27 +139,5 @@ public Map<String, ProductAttribute> getAll() {
public void setAll(Map<String, ProductAttribute> all) {
this.all = all;
}

public Map<String, ProductAttribute> getAggregatedAttributes() {
return aggregatedAttributes;
}

public void setAggregatedAttributes(Map<String, ProductAttribute> aggregatedAttributes) {
this.aggregatedAttributes = aggregatedAttributes;
}

public Set<ProductAttribute> getUnmapedAttributes() {
return unmapedAttributes;
}
//
// public void setUnmapedAttributes(Set<ProductAttribute> unmapedAttributes) {
// this.unmapedAttributes = unmapedAttributes;
// }
//

public void setUnmapedAttributes(Set<ProductAttribute> unmapedAttributes) {
this.unmapedAttributes = unmapedAttributes;
}


}

0 comments on commit e13b609

Please sign in to comment.