protected Object getValueId(Object value) { if (value instanceof EmbeddableEntity) { return null; } else if (value instanceof BaseGenericIdEntity) { return referenceToEntitySupport.getReferenceId((Entity) value); } else { return null; } }
@Override public EntitySnapshot getLastEntitySnapshot(Entity entity) { checkCompositePrimaryKey(entity); MetaClass metaClass = extendedEntities.getOriginalOrThisMetaClass(entity.getMetaClass()); View view = metadata.getViewRepository().getView(EntitySnapshot.class, "entitySnapshot.browse"); LoadContext<EntitySnapshot> lx = LoadContext.create(EntitySnapshot.class).setQuery(LoadContext .createQuery(format("select e from sys$EntitySnapshot e where e.entityMetaClass = :metaClass and" + " e.entity.%s = :entityId order by e.snapshotDate desc", referenceToEntitySupport.getReferenceIdPropertyName(metaClass))) .setParameter("metaClass", metaClass.getName()) .setParameter("entityId", referenceToEntitySupport.getReferenceId(entity)) .setMaxResults(1)) .setView(view); return dataManager.load(lx); }
public void search() { int maxRows; try { maxRows = Integer.parseInt(showRowField.getValue().toString()); if (maxRows >= 0) entityLogDs.setMaxResults(maxRows); else throw new NumberFormatException(); } catch (Exception e) { showNotification(messages.getMessage(getClass(), "invalidNumber"), NotificationType.HUMANIZED); return; } Entity entity = instancePicker.getValue(); Map<String, Object> params = new HashMap<>(); if (entity != null) { Object entityId = referenceToEntitySupport.getReferenceId(entity); if (entityId instanceof UUID) { params.put("entityId", entityId); } else if (entityId instanceof String) { params.put("stringEntityId", entityId); } else if (entityId instanceof Integer) { params.put("intEntityId", entityId); } else if (entityId instanceof Long) { params.put("longEntityId", entityId); } } entityLogDs.refresh(params); }
@Override public List<EntitySnapshot> getSnapshots(MetaClass metaClass, Object id) { metaClass = extendedEntities.getOriginalOrThisMetaClass(metaClass); Entity entity = dataManager.load(new LoadContext<>(metaClass).setId(id).setView(View.LOCAL)); checkCompositePrimaryKey(entity); List<EntitySnapshot> resultList = null; View view = metadata.getViewRepository().getView(EntitySnapshot.class, "entitySnapshot.browse"); Transaction tx = persistence.createTransaction(); try { EntityManager em = persistence.getEntityManager(); TypedQuery<EntitySnapshot> query = em.createQuery(format( "select s from sys$EntitySnapshot s where s.entity.%s = :entityId and s.entityMetaClass = :metaClass " + "order by s.snapshotDate desc", referenceToEntitySupport.getReferenceIdPropertyName(metaClass)), EntitySnapshot.class); query.setParameter("entityId", referenceToEntitySupport.getReferenceId(entity)); query.setParameter("metaClass", metaClass.getName()); query.setView(view); resultList = query.getResultList(); tx.commit(); } finally { tx.end(); } return resultList; }
.map(e -> referenceToEntitySupport.getReferenceId(e)) .collect(Collectors.toList()); Collection<CategoryAttributeValue> entityAttributeValues = allAttributeValues.get(referenceToEntitySupport.getReferenceId(entity)); Map<String, CategoryAttributeValue> map = new HashMap<>(); entity.setDynamicAttributes(map);
@SuppressWarnings("unchecked") protected boolean calculateFilteredData(Entity entity, Set<EntityId> handled, boolean checkPermitted) { if (referenceToEntitySupport.getReferenceId(entity) == null) { return false; return true; EntityId entityId = new EntityId(referenceToEntitySupport.getReferenceId(entity), metaClass.getName()); if (handled.contains(entityId)) { return false; for (Entity item : (Collection<Entity>) value) { if (calculateFilteredData(item, handled, true)) { filtered.add(referenceToEntitySupport.getReferenceId(item)); if (calculateFilteredData(valueEntity, handled, true)) { securityTokenManager.addFiltered(baseGenericIdEntity, property.getName(), referenceToEntitySupport.getReferenceId(valueEntity));
@SuppressWarnings("unchecked") protected void applyConstraints(Entity entity, Set<EntityId> handled) { MetaClass metaClass = entity.getMetaClass(); EntityId entityId = new EntityId(referenceToEntitySupport.getReferenceId(entity), metaClass.getName()); if (handled.contains(entityId)) { return; Entity item = iterator.next(); if (filteredData != null && filteredData.containsEntry(property.getName(), referenceToEntitySupport.getReferenceId(item))) { iterator.remove(); } else { referenceToEntitySupport.getReferenceId((Entity) value))) { baseGenericIdEntity.setValue(property.getName(), null); } else {
/** * @see Initializer#init(String, Entity) */ protected void init(String procCode, Entity entity) { ProcDefinition procDefinition = bpmEntitiesService.findProcDefinitionByCode(procCode, BpmConstants.Views.PROC_DEFINITION_WITH_ROLES); if (procDefinition == null) { log.debug("Process definition with code '{}' not found", procCode); return; } List<ProcInstance> procInstances = bpmEntitiesService.findActiveProcInstancesForEntity(procDefinition.getCode(), entity, BpmConstants.Views.PROC_INSTANCE_FULL); procInstance = procInstances.isEmpty() ? null : procInstances.get(0); if (procInstance == null) { procInstance = metadata.create(ProcInstance.class); procInstance.setProcDefinition(procDefinition); procInstance.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity)); procInstance.setEntityName(entity.getMetaClass().getName()); } init(procInstance); }
CollectionCompare.with() .onCreate(e -> { if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { Entity result = importEntity(e, null, viewProperty.getView(), regularView, commitContext, referenceInfoList, optimisticLocking); if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(src))) { Entity result = importEntity(src, dst, viewProperty.getView(), regularView, commitContext, referenceInfoList, optimisticLocking); if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { if (srcFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { newCollectionValue.add(e); } else if (viewProperty.getCollectionImportPolicy() == CollectionImportPolicy.KEEP_ABSENT_ITEMS) {
} else if (value instanceof BaseGenericIdEntity) { ReferenceToEntitySupport referenceToEntitySupport = AppBeans.get(ReferenceToEntitySupport.class); Object referenceId = referenceToEntitySupport.getReferenceId((BaseGenericIdEntity) value); entityValue.setObjectEntityId(referenceId); setTransientEntityValue((BaseGenericIdEntity) value);
protected EntitySnapshot createEntitySnapshot(Entity entity, View view, Date snapshotDate, User author) { Preconditions.checkNotNullArgument(entity); Preconditions.checkNotNullArgument(view); Preconditions.checkNotNullArgument(snapshotDate); checkCompositePrimaryKey(entity); Class viewEntityClass = view.getEntityClass(); Class entityClass = entity.getClass(); if (!viewEntityClass.isAssignableFrom(entityClass)) { throw new IllegalStateException("View could not be used with this propertyValue"); } MetaClass metaClass = extendedEntities.getOriginalOrThisMetaClass(metadata.getClass(entity.getClass())); EntitySnapshot snapshot = metadata.create(EntitySnapshot.class); snapshot.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity)); snapshot.setEntityMetaClass(metaClass.getName()); snapshot.setViewXml(viewSerializationAPI.toJson(view, ViewSerializationOption.COMPACT_FORMAT)); snapshot.setSnapshotXml(entitySerializationAPI.toJson(entity)); snapshot.setSnapshotDate(snapshotDate); snapshot.setAuthor(author); return snapshot; } }
item.setType(type); item.setEntity(metadata.getExtendedEntities().getOriginalOrThisMetaClass(metaClass).getName()); item.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity)); item.setAttributes(entityLogAttrs);
CollectionCompare.with() .onCreate(e -> { if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { Entity result = importEntity(e, null, viewProperty.getView(), regularView, commitContext, referenceInfoList, optimisticLocking); if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(src))) { Entity result = importEntity(src, dst, viewProperty.getView(), regularView, commitContext, referenceInfoList, optimisticLocking); Object refId = referenceToEntitySupport.getReferenceId(e); if (viewProperty.getCollectionImportPolicy() == CollectionImportPolicy.REMOVE_ABSENT_ITEMS) { if (!dstFilteredIds.contains(refId) && !srcFilteredIds.contains(refId)) {
CollectionCompare.with() .onCreate(e -> { if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { Entity result = findReferenceEntity(e, viewProperty, commitContext, loadedEntities); if (result != null) { if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(dst))) { Entity result = findReferenceEntity(src, viewProperty, commitContext, loadedEntities); if (result != null) { if (!dstFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { if (srcFilteredIds.contains(referenceToEntitySupport.getReferenceId(e))) { newCollectionValue.add(e); } else if (viewProperty.getCollectionImportPolicy() == CollectionImportPolicy.KEEP_ABSENT_ITEMS) {
protected void internalRegisterDelete(Entity entity, String entityName, Set<String> attributes) throws IOException { Date ts = timeSource.currentTimestamp(); EntityManager em = persistence.getEntityManager(); EntityLogItem item = metadata.create(EntityLogItem.class); item.setEventTs(ts); item.setUser(findUser(em)); item.setType(EntityLogItem.Type.DELETE); item.setEntity(entityName); item.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity)); item.setAttributes(createLogAttributes(entity, attributes, null)); enqueueItem(item); }
categoryAttributeValue.setObjectEntityId(referenceToEntitySupport.getReferenceId(this)); categoryAttributeValue.setCode(attributeCode); DynamicAttributes dynamicAttributesBean = AppBeans.get(DynamicAttributes.NAME);
protected void internalRegisterCreate(Entity entity, String entityName, Set<String> attributes) throws IOException { Date ts = timeSource.currentTimestamp(); EntityManager em = persistence.getEntityManager(); EntityLogItem item = metadata.create(EntityLogItem.class); item.setEventTs(ts); item.setUser(findUser(em)); item.setType(EntityLogItem.Type.CREATE); item.setEntity(entityName); if (entity instanceof BaseDbGeneratedIdEntity) { item.setDbGeneratedIdEntity((BaseDbGeneratedIdEntity) entity); } else { item.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity)); } item.setAttributes(createLogAttributes(entity, attributes, null)); enqueueItem(item); }
categoryAttributeValue.setObjectEntityId(referenceToEntitySupport.getReferenceId(entity));
Entity entity = e.getValue(); if (entity != null) { attribute.setObjectDefaultEntityId(referenceToEntitySupport.getReferenceId(entity)); } else { attribute.setObjectDefaultEntityId(null);
@Override public Component generateField(Datasource datasource, String propertyId) { entityIdPickerField = componentsFactory.createComponent(PickerField.class); entityIdPickerField.addLookupAction(); entityIdPickerField.addOpenAction(); entityIdPickerField.addClearAction(); Object entityId = getItem().getObjectEntityId(); String entityName = getItem().getEntityName(); MetaClass metaClass = metadata.getClass(entityName); entityIdPickerField.setMetaClass(metaClass); entityIdPickerField.setEditable(metaClass != null); if (entityId != null && metaClass != null) { Entity entity = findEntity(entityName, entityId); entityIdPickerField.setValue(entity); } entityIdPickerField.addValueChangeListener(e -> { Object entityId1 = e.getValue() == null ? null : referenceToEntitySupport.getReferenceId((Entity) e.getValue()); getItem().setObjectEntityId(entityId1); initOpenEntityBtn(); }); return entityIdPickerField; } });