static GenericValue setData(final User user, final GenericValue userGenericValue) { userGenericValue.setFields(getData(user)); return userGenericValue; }
public ImmutableGenericValue(GenericDelegator delegator, String entityName, Map fields) { super(delegator.getModelEntity(entityName)); super.setDelegator(delegator); super.setFields(fields); constructed = true; }
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException { GenericValue value = findFromCache(primaryKey); value.setFields(value.getFields(keys)); return value; }
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set keys) throws GenericEntityException { GenericValue value = findFromCache(primaryKey); value.setFields(value.getFields(keys)); return value; }
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set keys) throws GenericEntityException { GenericValue value = findFromCache(primaryKey); value.setFields(value.getFields(keys)); return value; }
@Override public void createAssociation(final String associationType, final String userName, final String sinkNodeEntity, final Long sinkNodeId) { GenericValue association = getAssociation(userName, sinkNodeId, sinkNodeEntity, associationType); if (association == null) { final FieldMap fields = FieldMap.build("associationType", associationType) .add("sourceName", userName).add("sinkNodeEntity", sinkNodeEntity).add("sinkNodeId", sinkNodeId) .add("created", new Timestamp(System.currentTimeMillis())); // Can't use ofBizDelegator.createValue() because this will try to force an "id" field into the GV final GenericValue genericValue = ofBizDelegator.makeValue("UserAssociation"); genericValue.setFields(fields); try { genericValue.create(); } catch (GenericEntityException e) { throw new DataAccessException(e); } } }
@Override public GenericValue createAssociation(String sourceNodeEntity, Long sourceNodeId, String sinkNodeEntity, Long sinkNodeId, String associationType) throws DataAccessException { GenericValue association = getAssociation(sourceNodeEntity, sourceNodeId, sinkNodeEntity, sinkNodeId, associationType); if (association == null) { // NodeAssociation does not have an ID field, therefore we can't use ofBizDelegator.createValue() association = ofBizDelegator.makeValue("NodeAssociation"); association.setFields(UtilMisc.toMap( "associationType", associationType, "sourceNodeId", sourceNodeId, "sourceNodeEntity", sourceNodeEntity, "sinkNodeId", sinkNodeId, "sinkNodeEntity", sinkNodeEntity)); try { association.create(); } catch (GenericEntityException ex) { throw new DataAccessException(ex); } } return association; }
private void associateSchemeWithProjects(final long classicSchemeId) throws GenericEntityException { List<GenericValue> allProjects = entityEngine.run(Select.columns("id").from("Project")).asList(); List<GenericValue> allProjectsWithSchemes = entityEngine.run(Select.columns("sourceNodeId") .from("NodeAssociation") .whereEqual("associationType", "ProjectScheme") .andEqual("sinkNodeEntity", "WorkflowScheme")).asList(); Set<Long> withoutSchemes = Sets.newHashSet(); for (GenericValue project : allProjects) { withoutSchemes.add(project.getLong("id")); } for (GenericValue project : allProjectsWithSchemes) { withoutSchemes.remove(project.getLong("sourceNodeId")); } GenericValue association; for (long projectId : withoutSchemes) { // NodeAssociation does not have an ID field, so we can't use ofBizDelegator.createValue() association = ofBizDelegator.makeValue("NodeAssociation"); association.setFields(ImmutableMap.of( "associationType", "ProjectScheme", "sourceNodeId", projectId, "sourceNodeEntity", "Project", "sinkNodeId", classicSchemeId, "sinkNodeEntity", "WorkflowScheme")); association.create(); } }
public TrustedApplicationData store(final TrustedApplicationData trustedApplicationData) { final Map<String, Object> map = new TrustedApplicationBuilder().set(trustedApplicationData).toMap(); final GenericValue oldValue = (trustedApplicationData.getId() > 0) ? findGenericValue(trustedApplicationData.getId()) : null; if (oldValue == null) { final GenericValue newValue = ofBizDelegator.createValue(ENTITY_NAME, map); return transform(newValue); } final GenericValue newValue = new GenericValue(oldValue); newValue.setFields(map); ofBizDelegator.store(newValue); return trustedApplicationData; }
@SuppressWarnings ("ConstantConditions") public void update(MailServer mailServer) throws MailException { try { GenericValue storedMailServer = getMailServerGV(mailServer.getId()); if (storedMailServer != null) { storedMailServer.setFields(getMapFromColumns(mailServer)); ComponentAccessor.getOfBizDelegator().store(storedMailServer); } else { throw new MailException("Server '" + mailServer.getId() +"' not found."); } } catch (DataAccessException e) { throw new MailException(e); } finally { cacheSupplier.get().remove(mailServer.getName()); } }