/** * Add a Regex Equality Filter to the Scanner, Will Filter Results Not Equal to the Filter Value * * @param fieldName The name of the column you want to apply the filter on * @param filterValue The regular expression to use for comparison * @return ScannerBuilder */ public EntityScannerBuilder<E> addRegexMatchFilter(String fieldName, String regexString) { RegexEntityFilter regexEntityFilter = new RegexEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, regexString); filterList.add(regexEntityFilter.getFilter()); return this; }
/** * Only include rows which have an empty value for this field * * @param fieldName The field to check nullity * @return ScannerBuilder */ public EntityScannerBuilder<E> addIsNullFilter(String fieldName) { RegexEntityFilter regexEntityFilter = new RegexEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, ".+", false); filterList.add(regexEntityFilter.getFilter()); return this; }
/** * Add an Inequality Filter to the Scanner, Will Filter Results Not Equal to the Filter Value * * @param fieldName The name of the column you want to apply the filter on * @param filterValue The value for comparison * @return ScannerBuilder */ public EntityScannerBuilder<E> addNotEqualFilter(String fieldName, Object filterValue) { SingleFieldEntityFilter singleFieldEntityFilter = new SingleFieldEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, filterValue, CompareFilter.CompareOp.NOT_EQUAL); filterList.add(singleFieldEntityFilter.getFilter()); return this; }
/** * Only include rows which are missing this field, this was the only possible way to do it. * * @param fieldName The field which should be missing * @return ScannerBuilder */ public EntityScannerBuilder<E> addIsMissingFilter(String fieldName) { SingleFieldEntityFilter singleFieldEntityFilter = new SingleFieldEntityFilter( entityMapper.getEntitySchema(), entityMapper.getEntitySerDe(), fieldName, "++++NON_SHALL_PASS++++", CompareFilter.CompareOp.EQUAL); SingleColumnValueFilter filter = (SingleColumnValueFilter) singleFieldEntityFilter.getFilter(); filter.setFilterIfMissing(false); filterList.add(filter); return this; }
public <T> T load(PersistenceContext context, Class<T> entityClass) { log.debug("Loading entity of class {} using PersistenceContext {}", entityClass, context); EntityMeta entityMeta = context.getEntityMeta(); Object primaryKey = context.getPrimaryKey(); Validator.validateNotNull(entityClass, "Entity class should not be null"); Validator.validateNotNull( primaryKey, "Entity '%s' key should not be null", entityClass.getCanonicalName()); Validator.validateNotNull( entityMeta, "Entity meta for '%s' should not be null", entityClass.getCanonicalName()); T entity = null; if (entityMeta.isClusteredCounter()) { entity = counterLoader.loadClusteredCounters(context); } else { Row row = context.loadEntity(); if (row != null) { entity = entityMeta.instanciate(); mapper.setNonCounterPropertiesToEntity(row, entityMeta, entity); } } return entity; }
public void loadPropertyIntoObject( PersistenceContext context, Object realObject, PropertyMeta pm) { log.trace("Loading property {} into object {}", pm.getPropertyName(), realObject); PropertyType type = pm.type(); if (type.isCounter()) { counterLoader.loadCounter(context, realObject, pm); } else { Row row = context.loadProperty(pm); mapper.setPropertyToEntity(row, pm, realObject); } }
/** * Returns a specific model by id. * * @param id the of the matching model * @return the request document as JSON */ @GET @Path("sales/{id}") public Response read(@PathParam("id") final String id, @Context final SecurityContext context) { ResponseBuilder response = null; final SaleData sale = mapper.fromEntity(dao.get(id)); if (sale == null) { response = Response.status(Status.NOT_FOUND); } else { response = Response.ok().entity(sale); } return response.build(); }
/** * Calls the Cloudera Navigator Mapper to map Lineage entities to Cloudera Navigator entities and * writes them to Cloudera Navigator using NavigatorPlugin. * * @param dieOnError throw or not a RuntimeException on error */ public void sendToLineageProvider(Boolean dieOnError) { try { // Start by writing the datasets ResultSet results = this.plugin.write(this.datasets); if (results.hasErrors()) { throw new RuntimeException(results.toString()); } // Create Cloudera navigator mapper EntityMapper tem = new EntityMapper(this.inputNavigatorNodes, this.jobName + this.projectName); tem.addTag(this.jobName); if (LOG.isDebugEnabled()) { for (NavigatorNode nn : this.inputNavigatorNodes) { LOG.debug(nn); } } // Map Lineage nodes to Cloudera navigator entities List<Entity> entities = tem.map(); LOG.debug(tem.toString()); // Write the rest of the entities (processing components) results = this.plugin.write(entities); if (results.hasErrors()) { throw new RuntimeException(results.toString()); } } catch (RuntimeException e) { if (dieOnError) { throw e; } else { LOG.error(e); } } }
/** * Example method to get multiple values. Shows use of a query param. * * @param title the title of models to find * @return a Response containing JSON data. */ @GET @Path("sales") public Response getAllValues( @QueryParam("page") final int page, @QueryParam("pageSize") final int pageSize, @QueryParam("orderby") final String orderby) { LOGGER.info("Count=" + dao.count()); final HouseSaleEntity[] all = dao.get(pageSize, page, orderby); LOGGER.info( "getAllValues(" + page + ", " + pageSize + ", " + orderby + "). Returned " + all.length + " values."); final SaleDataPage salePage = mapper.getPage(pageSize, page, all); return Response.ok().entity(salePage).build(); }
private Node<OWLObjectPropertyExpression> toObjectPropertyNode(Set<ATermAppl> terms) { return NodeFactory.getOWLObjectPropertyNode(OP_MAPPER.map(terms)); }
private Set<OWLLiteral> toLiteralSet(Collection<ATermAppl> terms) { return LIT_MAPPER.map(terms); }
private Node<OWLNamedIndividual> toIndividualNode(Set<ATermAppl> terms) { return NodeFactory.getOWLNamedIndividualNode(IND_MAPPER.map(terms)); }
private Node<OWLDataProperty> toDataPropertyNode(Set<ATermAppl> terms) { return NodeFactory.getOWLDataPropertyNode(DP_MAPPER.map(terms)); }
private Node<OWLClass> toClassNode(Set<ATermAppl> terms) { return NodeFactory.getOWLClassNode(CLASS_MAPPER.map(terms)); }