
nl.tno.bim.nmd.domain.NmdBaseProductCard Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bimnmdservice Show documentation
Show all versions of bimnmdservice Show documentation
provides a REST api for retrieving nmd data from various data sources
The newest version!
package nl.tno.bim.nmd.domain;
import java.util.Collection;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import nl.tno.bim.nmd.scaling.NmdScaler;
public class NmdBaseProductCard implements NmdProductCard {
private String description;
private Set specifications;
private String unit;
private Integer category;
private Integer productLifetime;
private Integer parentId;
private Integer id;
private NlsfbCode nlsfbCode;
public NmdBaseProductCard() {
this.specifications = new HashSet();
this.description = "";
}
/**
* Copy constructor
*
* @param p input product card
*/
public NmdBaseProductCard(NmdProductCard p) {
if (p == null) {
p = new NmdBaseProductCard();
}
this.id = p.getProductId();
this.parentId = p.getParentProductId();
this.specifications = new HashSet();
this.specifications.addAll(p.getProfileSets());
this.setLifetime(p.getLifetime());
this.setCategory(p.getCategory());
this.setNlsfbCode(p.getNlsfbCode());
this.setUnit(p.getUnit());
this.setDescription(p.getDescription());
}
@Override
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public NlsfbCode getNlsfbCode() {
return this.nlsfbCode;
}
public void setNlsfbCode(NlsfbCode code) {
this.nlsfbCode = code;
}
@Override
public String getUnit() {
return this.unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
@Override
public Set getProfileSets() {
return this.specifications;
}
public Optional getProfileSetByName(String name) {
return this.specifications.stream().filter(ps -> ps.getName().equals(name)).findFirst();
}
@Override
public void addProfileSet(NmdProfileSet spec) {
if (spec != null) {
this.specifications.add(spec);
}
}
@Override
public void addProfileSets(Collection specs) {
if (specs != null && specs.size() > 0) {
this.specifications.addAll(specs);
}
}
@Override
public Integer getCategory() {
return this.category;
}
public void setCategory(Integer cat) {
this.category = cat;
}
@Override
public Integer getLifetime() {
return this.productLifetime;
}
public void setLifetime(Integer lifetime) {
this.productLifetime = lifetime;
}
@Override
public Integer getParentProductId() {
return this.parentId;
}
public void setParentProductId(Integer id) {
this.parentId = id;
}
@Override
public Integer getProductId() {
return this.id;
}
public void setProductId(Integer id) {
this.id = id;
}
@Override
public Double getProfileSetsCoeficientSum() {
return this.getProfileSets().stream()
.collect(Collectors.summingDouble(ps -> ps.getCoefficientSum()));
}
@Override
public NmdScaler getScalerForProfileSet(Integer psId) {
Optional ps = this.getProfileSets().stream()
.filter(pset -> pset.getProfielId().equals(psId)).findFirst();
return ps.isPresent() ? ps.get().getScaler() : null;
}
@Override
public boolean requiresScaling() {
return !this.getUnit().equals("p");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy