package com.ctl.vnom.cache.searchmapping; import java.lang.annotation.ElementType; import org.hibernate.search.annotations.Factory; import org.hibernate.search.cfg.SearchMapping; import com.ctl.vnom.api.common.EVCDetails; import com.ctl.vnom.api.common.InventoryItem; import com.ctl.vnom.api.common.InventoryLocation; import com.ctl.vnom.api.common.RelatedInventory; import com.ctl.vnom.api.ld.CUGDetails; /** * @author jxredd5 * This class to is to let the hibernate search know of all the fields in the pojos we intend to index. * This is the programmatic way of doing it in addition to the annotation way of doing it on the pojo classes itself. * With the vipr framework of provding the pojo apis as modules, the annotations on the pojos does not seem to be available runtime * with the app throwing the field not indexed while putting the objects in the cache for querying. * * So to work around the issue, found that we can specify a mapping factory as part of the hibernate search properties we specify as part of the * infinispan config file. * * The class has to have a method annotated with @Factory and return a SearchMapping object with all the indexing configuration. */ public class ViprQciSearchMappingFactory { @Factory public SearchMapping getSearchMapping(){ SearchMapping mapping = new SearchMapping(); mapping.entity(InventoryItem.class) .indexed().providedId() .property("serviceId", ElementType.METHOD).field() .property("serviceAliasName", ElementType.METHOD).field() .property("serviceObjectId", ElementType.METHOD).field() .property("customerAccountId", ElementType.METHOD).field() .property("enterpriseId", ElementType.METHOD).field() .property("productTypeCode", ElementType.METHOD).field() .property("inventorySummaryId", ElementType.METHOD).field() .property("productFamilyCode", ElementType.METHOD).field() .property("productFamilyName", ElementType.METHOD).field() .property("serviceTypeCode", ElementType.METHOD).field() .property("callPlan", ElementType.METHOD).field() .property("group_callPlan_desc", ElementType.METHOD).field() .property("termination_trunkGroup", ElementType.METHOD).field() .property("inventoryTypeCode", ElementType.METHOD).field() .property("accountSystemCode", ElementType.METHOD).field() .property("serviceName", ElementType.METHOD).field() .property("productAccountId", ElementType.METHOD).field() .property("serviceCategoryId", ElementType.METHOD).field() .property("serviceElementId", ElementType.METHOD).field() .property("diversityIndicator", ElementType.METHOD).field() .property("inventoryId", ElementType.METHOD).field() .property("contractTerminationDate", ElementType.METHOD).field() .property("installationDate", ElementType.METHOD).field() .property("bandwidth", ElementType.METHOD).field() .property("switchId", ElementType.METHOD).field() .property("tenantId", ElementType.METHOD).field() .property("sipSwitchId", ElementType.METHOD).field() .property("totalSessions", ElementType.METHOD).field() .property("availableSessions", ElementType.METHOD).field() .property("poolType", ElementType.METHOD).field() .property("customName", ElementType.METHOD).field() .property("bansAccountNumber", ElementType.METHOD).field() .property("realIpV6", ElementType.METHOD).field() .property("realIp", ElementType.METHOD).field() .property("managedIpV6", ElementType.METHOD).field() .property("managedIp", ElementType.METHOD).field() .property("parentInventory", ElementType.METHOD).indexEmbedded() .property("childInventory", ElementType.METHOD).indexEmbedded() .property("location", ElementType.METHOD).indexEmbedded() .property("cugs", ElementType.METHOD).indexEmbedded(); mapping.entity(InventoryLocation.class).indexed().providedId() .property("city", ElementType.METHOD).field() .property("locationName", ElementType.METHOD).field() .property("clliCode", ElementType.METHOD).field() .property("countryCode", ElementType.METHOD).field() .property("serviceAddressId", ElementType.METHOD).field() .property("postalCode", ElementType.METHOD).field() .property("locationId", ElementType.METHOD).field() .property("locationTypeCode", ElementType.METHOD).field() .property("stateProvinceCode", ElementType.METHOD).field() .property("addressLine1", ElementType.METHOD).field() .property("addressLine2", ElementType.METHOD).field() .property("addressLine3", ElementType.METHOD).field(); mapping.entity(RelatedInventory.class).indexed().providedId() .property("inventoryId", ElementType.METHOD).field() .property("inventoryTypeCode", ElementType.METHOD).field() .property("serviceAliasName", ElementType.METHOD).field() .property("serviceId", ElementType.METHOD).field() .property("serviceTypeCode", ElementType.METHOD).field() .property("productTypeCode", ElementType.METHOD).field(); mapping.entity(CUGDetails.class).indexed().providedId() .property("cugId", ElementType.METHOD).field() .property("cugName", ElementType.METHOD).field() .property("networkName", ElementType.METHOD).field() .property("cugAliasName", ElementType.METHOD).field(); mapping.entity(EVCDetails.class).indexed().providedId() .property("id", ElementType.METHOD).field() .property("customName", ElementType.METHOD).field() .property("bandwidth", ElementType.METHOD).field() .property("memberObjectId", ElementType.METHOD).field(); return mapping; } }