org.spin.util.support.elasticsearch.Attribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of store Show documentation
Show all versions of store Show documentation
Web Store Functionality, a integration with VueStoreFront
/*************************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2012-2018 E.R.P. Consultores y Asociados, C.A. *
* Contributor(s): Yamel Senih [email protected] *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see . *
************************************************************************************/
package org.spin.util.support.elasticsearch;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.compiere.model.MAttribute;
import org.compiere.model.MAttributeValue;
/**
* Wrapper for product attribute entity
* @author Yamel Senih, [email protected], ERPCyA http://www.erpya.com
*/
public class Attribute implements IPersistenceWrapper {
/** Map */
Map map;
/** Product */
private MAttribute attribute;
/** Attributes values */
private List attributeValues;
/**
* Static builder
* @return
*/
public static Attribute newInstance() {
return new Attribute();
}
/**
* Set attribute set
* @param attribute
* @return
*/
public Attribute withAttribute(MAttribute attribute) {
this.attribute = attribute;
return this;
}
/**
* Private constructor
*/
private Attribute() {
map = new HashMap();
}
/**
* https://docs.storefrontapi.com/guide/integration/integration.html#category-entity
*/
@Override
public Map getMap() {
map = new HashMap();
// Instance
Map attributeMap = new HashMap();
map.put("id", attribute.getM_Attribute_ID());
// TODO: Make this dynamic
map.put("is_user_defined", true);
map.put("is_visible", true);
map.put("attribute_code", getValidValue(attribute.getName()));
map.put("default_frontend_label", attribute.getName());
// For list of values
if(attribute.getAttributeValueType().equals(MAttribute.ATTRIBUTEVALUETYPE_List)) {
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy