本文整理汇总了Java中org.jai.search.model.ProductProperty类的典型用法代码示例。如果您正苦于以下问题:Java ProductProperty类的具体用法?Java ProductProperty怎么用?Java ProductProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProductProperty类属于org.jai.search.model包,在下文中一共展示了ProductProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getXContentBuilderForAProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private XContentBuilder getXContentBuilderForAProductProperty(ProductProperty productProperty)
{
XContentBuilder contentBuilder = null;
try
{
contentBuilder = jsonBuilder().prettyPrint().startObject();
contentBuilder.field(SearchDocumentFieldName.SIZE.getFieldName(), productProperty.getSize())
.field(SearchDocumentFieldName.COLOR.getFieldName(), productProperty.getColor())
;
contentBuilder.endObject();
}
catch (IOException ex)
{
logger.error(ex.getMessage());
throw new RuntimeException("Error occured while creating product gift json document!", ex);
}
return contentBuilder;
}
示例2: filteringOnChildDocumentsOnProductProperties
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
@Test
public void filteringOnChildDocumentsOnProductProperties()
{
//set up parent child relationship docs
setupIndexService.setupAllIndices(true);
refreshSearchServer();
ElasticSearchIndexConfig config = ElasticSearchIndexConfig.COM_WEBSITE;
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.indices(config.getIndexAliasName());
searchCriteria.documentTypes(config.getDocumentType());
//search for the products for productproperties
ProductProperty findProductProperty = sampleDataGenerator.findProductProperty(SampleDataGenerator.PRODUCTPROPERTY_SIZE_21_INCH, SampleDataGenerator.PRODUCTPROPERTY_COLOR_BROWN);
assertNotNull(findProductProperty);
searchCriteria.addProductProperty(findProductProperty);
ProductSearchResult searchProducts = productQueryService.searchProducts(searchCriteria);
assertEquals(1, searchProducts.getTotalCount());
assertEquals(1, searchProducts.getProducts().size());
}
示例3: getProductProperties
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private static Set<ProductProperty> getProductProperties()
{
final Set<ProductProperty> productProperties = new HashSet<ProductProperty>();
final String[] sizes = new String[] { PRODUCTPROPERTY_SIZE_12_INCH, PRODUCTPROPERTY_SIZE_13_INCH, PRODUCTPROPERTY_SIZE_15_INCH,
PRODUCTPROPERTY_SIZE_17_INCH, PRODUCTPROPERTY_SIZE_21_INCH };
final String[] colors = new String[] { PRODUCTPROPERTY_COLOR_BLACK, PRODUCTPROPERTY_COLOR_GREY, PRODUCTPROPERTY_COLOR_YELLOW,
PRODUCTPROPERTY_COLOR_PURPLE, PRODUCTPROPERTY_COLOR_BROWN };
for (int i = 1; i <= 5; i++)
{
final ProductProperty productProperty = new ProductProperty();
productProperty.setId(Long.valueOf(i));
// if (i <= 5)
// {
productProperty.setSize(sizes[i - 1]);
productProperty.setColor(colors[i - 1]);
// }
// else
// {
// productProperty.setSize(sizes[j++]);
// productProperty.setColor(colors[9 - i]);
// }
productProperties.add(productProperty);
}
logger.debug(productProperties.toString());
return productProperties;
}
示例4: indexProductPropterty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
@Override
public void indexProductPropterty(final ElasticSearchIndexConfig config, final String indexName, final ProductProperty productProperty)
{
String indexNameUsed = indexName;
if (StringUtils.isBlank(indexName))
{
indexNameUsed = config.getIndexAliasName();
}
try
{
// To parent-child for now.
getIndexRequestBuilderForAProductProperty(null, productProperty, config, indexNameUsed).get();
}
catch (final Exception ex)
{
logger.error("Error occurred while creating index document for product.", ex);
throw new RuntimeException(ex);
}
}
示例5: getXContentBuilderForAProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private XContentBuilder getXContentBuilderForAProductProperty(final ProductProperty productProperty)
{
XContentBuilder contentBuilder = null;
try
{
contentBuilder = jsonBuilder().prettyPrint().startObject();
contentBuilder.field(SearchDocumentFieldName.SIZE.getFieldName(), productProperty.getSize()).field(
SearchDocumentFieldName.COLOR.getFieldName(), productProperty.getColor());
contentBuilder.endObject();
}
catch (final IOException ex)
{
logger.error(ex.getMessage());
throw new RuntimeException("Error occured while creating product gift json document!", ex);
}
return contentBuilder;
}
示例6: getProductProperties
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private static Set<ProductProperty> getProductProperties() {
final Set<ProductProperty> productProperties = new HashSet<ProductProperty>();
final String[] sizes = new String[] { PRODUCTPROPERTY_SIZE_12_INCH,
PRODUCTPROPERTY_SIZE_13_INCH, PRODUCTPROPERTY_SIZE_15_INCH,
PRODUCTPROPERTY_SIZE_17_INCH, PRODUCTPROPERTY_SIZE_21_INCH };
final String[] colors = new String[] { PRODUCTPROPERTY_COLOR_BLACK,
PRODUCTPROPERTY_COLOR_GREY, PRODUCTPROPERTY_COLOR_YELLOW,
PRODUCTPROPERTY_COLOR_PURPLE, PRODUCTPROPERTY_COLOR_BROWN };
for (int i = 1; i <= 5; i++) {
final ProductProperty productProperty = new ProductProperty();
productProperty.setId(Long.valueOf(i));
// if (i <= 5)
// {
productProperty.setSize(sizes[i - 1]);
productProperty.setColor(colors[i - 1]);
// }
// else
// {
// productProperty.setSize(sizes[j++]);
// productProperty.setColor(colors[9 - i]);
// }
productProperties.add(productProperty);
}
logger.debug(productProperties.toString());
return productProperties;
}
示例7: indexProductPropterty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
@Override
public void indexProductPropterty(final ElasticSearchIndexConfig config,
final String indexName, final ProductProperty productProperty) {
String indexNameUsed = indexName;
if (StringUtils.isBlank(indexName)) {
indexNameUsed = config.getIndexAliasName();
}
try {
// To parent-child for now.
getIndexRequestBuilderForAProductProperty(null, productProperty,
config, indexNameUsed).get();
} catch (final Exception ex) {
logger.error(
"Error occurred while creating index document for product.",
ex);
throw new RuntimeException(ex);
}
}
示例8: getIndexRequestBuilderForAProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private IndexRequestBuilder getIndexRequestBuilderForAProductProperty(
final Product product, final ProductProperty productProperty,
final ElasticSearchIndexConfig config, final String indexNameUsed)
throws IOException {
final XContentBuilder contentBuilder = getXContentBuilderForAProductProperty(productProperty);
final String documentId = (product != null ? String.valueOf(product
.getId()) : "")
+ String.valueOf(productProperty.getId())
+ "0000";
logger.debug("Generated XContentBuilder for document id {} is {}",
new Object[] { documentId,
contentBuilder.prettyPrint().string() });
final IndexRequestBuilder indexRequestBuilder = searchClientService
.getClient().prepareIndex(indexNameUsed,
config.getPropertiesDocumentType(), documentId);
indexRequestBuilder.setSource(contentBuilder);
return indexRequestBuilder;
}
示例9: getXContentBuilderForAProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private XContentBuilder getXContentBuilderForAProductProperty(
final ProductProperty productProperty) {
XContentBuilder contentBuilder = null;
try {
contentBuilder = jsonBuilder().prettyPrint().startObject();
contentBuilder.field(SearchDocumentFieldName.SIZE.getFieldName(),
productProperty.getSize()).field(
SearchDocumentFieldName.COLOR.getFieldName(),
productProperty.getColor());
contentBuilder.endObject();
} catch (final IOException ex) {
logger.error(ex.getMessage());
throw new RuntimeException(
"Error occured while creating product gift json document!",
ex);
}
return contentBuilder;
}
示例10: getProductProperties
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private Set<ProductProperty> getProductProperties()
{
Set<ProductProperty> productProperties = new HashSet<ProductProperty>();
String[] sizes = new String[] {PRODUCTPROPERTY_SIZE_12_INCH,
PRODUCTPROPERTY_SIZE_13_INCH,
PRODUCTPROPERTY_SIZE_15_INCH,
PRODUCTPROPERTY_SIZE_17_INCH,
PRODUCTPROPERTY_SIZE_21_INCH
};
String[] colors = new String[] {PRODUCTPROPERTY_COLOR_BLACK,
PRODUCTPROPERTY_COLOR_GREY,
PRODUCTPROPERTY_COLOR_YELLOW,
PRODUCTPROPERTY_COLOR_PURPLE,
PRODUCTPROPERTY_COLOR_BROWN
};
for (int i = 0, j=0; i < 10; i++)
{
ProductProperty productProperty = new ProductProperty();
productProperty.setId(Long.valueOf(i));
if(i<5)
{
productProperty.setSize(sizes[i]);
productProperty.setColor(colors[i]);
}
else
{
productProperty.setSize(sizes[j++]);
productProperty.setColor(colors[9-i]);
}
productProperties.add(productProperty);
}
System.out.println(productProperties);
return productProperties;
}
示例11: findProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private ProductProperty findProductProperty(Set<ProductProperty> productProperties, String size, String color)
{
for (ProductProperty productProperty : productProperties)
{
if(size.equals(productProperty.getSize()) && color.equals(productProperty.getColor()))
{
return productProperty;
}
}
return null;
}
示例12: indexAllProductGroupData
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
@Override
public void indexAllProductGroupData(ElasticSearchIndexConfig config, List<ProductGroup> productGroups, boolean parentRelationShip)
{
List<IndexRequestBuilder> requests = new ArrayList<IndexRequestBuilder>();
for (ProductGroup productGroup : productGroups)
{
try
{
requests.add(getIndexRequestBuilderForAProductGroup(productGroup, config));
//Index all products data also with parent
for (Product product : productGroup.getProducts())
{
IndexRequestBuilder indexRequestBuilderForAProduct = getIndexRequestBuilderForAProduct(product, config);
if(parentRelationShip)
{
indexRequestBuilderForAProduct.setParent(String.valueOf(productGroup.getId()));
}
requests.add(indexRequestBuilderForAProduct);
for (ProductProperty productProperty : product.getProductProperties())
{
IndexRequestBuilder indexRequestBuilderForAProductProperty = getIndexRequestBuilderForAProductProperty(product, productProperty, config);
if(parentRelationShip)
{
indexRequestBuilderForAProductProperty.setParent(String.valueOf(product.getId()));
}
requests.add(indexRequestBuilderForAProductProperty);
}
}
}
catch (Exception ex)
{
logger.error("Error occurred while creating index document for gift with id: " + productGroup.getId()
+ ", moving to next gift!", ex);
}
}
processBulkRequests(requests);
}
示例13: findProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private static ProductProperty findProductProperty(final Set<ProductProperty> productProperties, final String size, final String color)
{
for (final ProductProperty productProperty : productProperties)
{
if (size.equals(productProperty.getSize()) && color.equals(productProperty.getColor()))
{
return productProperty;
}
}
return null;
}
示例14: generateProductPropertySampleDataFor
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
@Override
public ProductProperty generateProductPropertySampleDataFor(final Long productPropertyId)
{
for (final ProductProperty productProperty : productProperties)
{
if (productProperty.getId().equals(productPropertyId))
{
return productProperty;
}
}
return null;
}
示例15: getIndexRequestBuilderForAProductProperty
import org.jai.search.model.ProductProperty; //导入依赖的package包/类
private IndexRequestBuilder getIndexRequestBuilderForAProductProperty(final Product product, final ProductProperty productProperty,
final ElasticSearchIndexConfig config, final String indexNameUsed) throws IOException
{
final XContentBuilder contentBuilder = getXContentBuilderForAProductProperty(productProperty);
final String documentId = (product != null ? String.valueOf(product.getId()) : "") + String.valueOf(productProperty.getId())
+ "0000";
logger.debug("Generated XContentBuilder for document id {} is {}",
new Object[] { documentId, contentBuilder.prettyPrint().string() });
final IndexRequestBuilder indexRequestBuilder = searchClientService.getClient().prepareIndex(indexNameUsed,
config.getPropertiesDocumentType(), documentId);
indexRequestBuilder.setSource(contentBuilder);
return indexRequestBuilder;
}