/** * Returns the resolved MulchEvents entity. * * @return an resolved entity */ public MulchEvent resolveEntity(EntityManager em) { MulchLevel mulchLevels = entity.getMulchLevel(); if (mulchLevels != null) { entity.setMulchLevel(em.getReference(MulchLevel.class, mulchLevels.getMulchLevelPK())); } return entity; }
/** * Getter for mulchLevels. * * @return value for mulchLevels */ @XmlElement public MulchLevelConverter getMulchLevel() { if (expandLevel > 0) { if (entity.getMulchLevel() != null) { return new MulchLevelConverter( entity.getMulchLevel(), uri.resolve("mulchLevel/"), expandLevel - 1, false); } } return null; }
/** * Updates entity using data from newEntity. * * @param entity the entity to update * @param newEntity the entity containing the new data * @return the updated entity */ private MulchEvent updateEntity(MulchEvent entity, MulchEvent newEntity) { EntityManager em = PersistenceService.getInstance().getEntityManager(); MulchLevel mulchLevels = entity.getMulchLevel(); MulchLevel mulchLevelsNew = newEntity.getMulchLevel(); entity = em.merge(newEntity); if (mulchLevels != null && !mulchLevels.equals(mulchLevelsNew)) { mulchLevels.getMulchEventsCollection().remove(entity); } if (mulchLevelsNew != null && !mulchLevelsNew.equals(mulchLevels)) { mulchLevelsNew.getMulchEventsCollection().add(entity); } return entity; }
/** * Creates a new instance of MulchEventConverter. * * @param entity associated entity * @param uri associated uri * @param expandLevel indicates the number of levels the entity graph should be expanded@param * isUriExtendable indicates whether the uri can be extended */ public MulchEventConverter(MulchEvent entity, URI uri, int expandLevel, boolean isUriExtendable) { this.entity = entity; this.uri = (isUriExtendable) ? UriBuilder.fromUri(uri) .path( entity.getMulchEventPK().getExpId() + "," + entity.getMulchEventPK().getMl() + "," + entity.getMulchEventPK().getMlApplNo() + "/") .build() : uri; this.expandLevel = expandLevel; getMulchLevel(); }
/** * Deletes the entity. * * @param entity the entity to deletle */ private void deleteEntity(MulchEvent entity) { EntityManager em = PersistenceService.getInstance().getEntityManager(); MulchLevel mulchLevels = entity.getMulchLevel(); if (mulchLevels != null) { mulchLevels.getMulchEventsCollection().remove(entity); } em.remove(entity); }
@Override public int hashCode() { int hash = uri == null ? 0 : uri.hashCode(); if (expandLevel <= 0) { return hash + 37 * expandLevel; } return hash + 37 * (expandLevel + 37 * (entity == null ? 0 : entity.hashCode())); }
@Override protected MulchLevel getEntity() { MulchLevel entity = parent.getMulchLevel(); if (entity == null) { throw new WebApplicationException( new Throwable("Resource for " + uriInfo.getAbsolutePath() + " does not exist."), 404); } return entity; }
/** * Returns the MulchEvents entity. * * @return an entity */ @XmlTransient public MulchEvent getEntity() { if (entity.getMulchEventPK() == null) { MulchEventConverter converter = UriResolver.getInstance().resolve(MulchEventConverter.class, uri); if (converter != null) { entity = converter.getEntity(); } } return entity; }
/** * Setter for mltp. * * @param value the value to set */ public void setMltp(String value) { entity.setMltp(value); }
/** * Setter for mlthk. * * @param value the value to set */ public void setMlthk(Float value) { entity.setMlthk(value); }
/** * Getter for mlcol. * * @return value for mlcol */ @XmlElement public String getMlcol() { return (expandLevel > 0) ? entity.getMlcol() : null; }
/** * Setter for mldat. * * @param value the value to set */ public void setMldat(Date value) { entity.setMldat(value); }
/** * Getter for mldat. * * @return value for mldat */ @XmlElement public Date getMldat() { return (expandLevel > 0) ? entity.getMldat() : null; }
/** * Setter for mulchEventsPK. * * @param value the value to set */ public void setMulchEventPK(MulchEventPK value) { entity.setMulchEventPK(value); }
/** * Getter for mulchEventsPK. * * @return value for mulchEventsPK */ @XmlElement public MulchEventPK getMulchEventPK() { return (expandLevel > 0) ? entity.getMulchEventPK() : null; }
/** * Setter for mlcol. * * @param value the value to set */ public void setMlcol(String value) { entity.setMlcol(value); }
/** * Getter for mlthk. * * @return value for mlthk */ @XmlElement public Float getMlthk() { return (expandLevel > 0) ? entity.getMlthk() : null; }
/** * Setter for mulchLevels. * * @param value the value to set */ public void setMulchLevel(MulchLevelConverter value) { entity.setMulchLevel((value != null) ? value.getEntity() : null); }