protected Report reloadReport(Report report) { View view = new View(Report.class) .addProperty("name") .addProperty("localeNames") .addProperty("description") .addProperty("templates") .addProperty("defaultTemplate") .addProperty("code") .addProperty("xml"); return dataManager.reload(report, view); } }
protected void reloadProcInstance() { View view = new View(ProcInstance.class) .addProperty("procDefinition", new View(ProcDefinition.class).addProperty("actProcessInstanceId")); procInstance = dataManager.reload(procInstance, view); }
protected void reloadProcTask() { View view = new View(ProcTask.class) .addProperty("actExecutionId"); procTask = dataManager.reload(procTask, view); }
@Nullable protected ProcModel findModelByName(String modelName) { View view = new View(ProcModel.class) .addProperty("name") .addProperty("actModelId"); LoadContext<ProcModel> ctx = LoadContext.create(ProcModel.class).setView(view); ctx.setQueryString("select m from bpm$ProcModel m where m.name = :name") .setParameter("name", modelName); return dataManager.load(ctx); }
protected List<CategoryAttributeValue> reloadCategoryAttributeValuesWithChildren(List<CategoryAttributeValue> categoryAttributeValues) { EntityManager em = persistence.getEntityManager(); View categoryAttributeValueLocalView = viewRepository.getView(CategoryAttributeValue.class, View.LOCAL); View categoryAttributeLocalView = viewRepository.getView(CategoryAttribute.class, View.LOCAL); View view = new View(categoryAttributeValueLocalView, null, false) .addProperty("categoryAttribute", new View(categoryAttributeLocalView, null, false).addProperty("category")) .addProperty("childValues", categoryAttributeValueLocalView); List<UUID> ids = categoryAttributeValues.stream() .map(BaseUuidEntity::getId) .collect(Collectors.toList()); return em.createQuery("select cav from sys$CategoryAttributeValue cav where cav.id in :ids", CategoryAttributeValue.class) .setParameter("ids", ids) .setView(view) .getResultList(); }
public View(ViewParams viewParams) { this.entityClass = viewParams.entityClass; this.name = viewParams.name != null ? viewParams.name : ""; if (viewParams.includeSystemProperties) { for (String propertyName : findSystemProperties(entityClass)) { addProperty(propertyName); } } List<View> sources = viewParams.src; if (isNotEmpty(sources)) { Class<? extends Entity> entityClass = sources.get(0).entityClass; if (this.entityClass == null) { this.entityClass = entityClass; } for (View view : sources) { putProperties(this.properties, view.getProperties()); } } }
protected View buildView(MetaClass metaClass, List<MetaProperty> props) { View view = new View(metaClass.getJavaClass()); for (MetaProperty property : props) { if (Entity.class.isAssignableFrom(property.getJavaType())) { view.addProperty(property.getName(), viewRepository.getView((Class) property.getJavaType(), View.MINIMAL)); } else { view.addProperty(property.getName()); } } return view; }
public String loadReportsList() { checkCanReadEntity(metadata.getClassNN(Report.class)); LoadContext<Report> loadContext = new LoadContext<>(Report.class); loadContext.setView( new View(Report.class) .addProperty("id") .addProperty("name") .addProperty("code")) .setQueryString("select r from report$Report r where r.restAccess = true"); reportSecurityManager.applySecurityPolicies(loadContext, null, userSessionSource.getUserSession().getCurrentOrSubstitutedUser()); List<Report> reports = dataManager.loadList(loadContext); List<ReportInfo> objects = reports.stream() .map(this::mapToReportInfo) .collect(Collectors.toList()); return createGson().toJson(objects); }
protected void addPersistentAttributeToMinimalView(MetaClass metaClass, Set<ViewInfo> visited, ViewInfo info, View view, MetaProperty metaProperty) { if (metaProperty.getRange().isClass() && !metaProperty.getRange().getCardinality().isMany()) { Map<String, View> views = storage.get(metaProperty.getRange().asClass()); View refMinimalView = (views == null ? null : views.get(View.MINIMAL)); if (refMinimalView != null) { view.addProperty(metaProperty.getName(), refMinimalView); } else { visited.add(info); View referenceMinimalView = deployDefaultView(metaProperty.getRange().asClass(), View.MINIMAL, visited); visited.remove(info); view.addProperty(metaProperty.getName(), referenceMinimalView); } } else { view.addProperty(metaProperty.getName()); } }
/** * Search for view for parent node * If does not exists - createDataSet it and add property to parent of parent view */ protected View ensureParentViewsExist(EntityTreeNode entityTreeNode, Map<EntityTreeNode, View> viewsForNodes) { EntityTreeNode parentNode = entityTreeNode.getParent(); View parentView = viewsForNodes.get(parentNode); if (parentView == null && parentNode != null) { parentView = new View(parentNode.getWrappedMetaClass().getJavaClass()); viewsForNodes.put(parentNode, parentView); View parentOfParentView = ensureParentViewsExist(parentNode, viewsForNodes); if (parentOfParentView != null) { parentOfParentView.addProperty(parentNode.getName(), parentView); } } return parentView; }
protected View createFullView(MetaClass metaClass) { View view = new View(metaClass.getJavaClass()); for (MetaProperty metaProperty : metaClass.getProperties()) { if (metadataTools.isEmbedded(metaProperty)) { view.addProperty(metaProperty.getName(), createFullView(metaProperty.getRange().asClass())); } else if (isReferenceField(metaProperty)) { view.addProperty(metaProperty.getName(), viewRepository.getView(metaProperty.getRange().asClass(), View.MINIMAL)); } else if (isDataField(metaProperty)) { view.addProperty(metaProperty.getName()); } } return view; }
public static View copy(@Nullable View view) { if (view == null) { return null; } View.ViewParams viewParams = new View.ViewParams() .entityClass(view.getEntityClass()) .name(view.getName()); View copy = new View(viewParams); for (ViewProperty property : view.getProperties()) { copy.addProperty(property.getName(), copy(property.getView()), property.getFetchMode()); } return copy; }
protected void addAttributesToLocalView(MetaClass metaClass, View view) { for (MetaProperty property : metaClass.getProperties()) { if (!property.getRange().isClass() && !metadata.getTools().isSystem(property) && metadata.getTools().isPersistent(property)) { view.addProperty(property.getName()); } } }
protected View copyView(@Nullable View view) { if (view == null) { return null; } View.ViewParams viewParams = new View.ViewParams() .entityClass(view.getEntityClass()) .name(view.getName()); View copy = new View(viewParams); for (ViewProperty property : view.getProperties()) { copy.addProperty(property.getName(), copyView(property.getView()), property.getFetchMode()); } return copy; }
public static View intersectViews(View first, View second) { if (first == null) throw new IllegalArgumentException("View is null"); if (second == null) throw new IllegalArgumentException("View is null"); View resultView = new View(first.getEntityClass()); Collection<ViewProperty> firstProps = first.getProperties(); for (ViewProperty firstProperty : firstProps) { if (second.containsProperty(firstProperty.getName())) { View resultPropView = null; ViewProperty secondProperty = second.getProperty(firstProperty.getName()); if ((firstProperty.getView() != null) && (secondProperty.getView() != null)) { resultPropView = intersectViews(firstProperty.getView(), secondProperty.getView()); } resultView.addProperty(firstProperty.getName(), resultPropView); } } return resultView; } }
protected void copyViewProperties(View src, View target, MetaClass metaClass) { for (ViewProperty viewProperty : src.getProperties()) { MetaProperty metaProperty = metaClass.getProperty(viewProperty.getName()); if (metaProperty == null || !metadata.getTools().isSystemLevel(metaProperty)) { if (!target.containsProperty(viewProperty.getName())) { target.addProperty(viewProperty.getName(), viewProperty.getView(), viewProperty.getFetchMode()); } } } }
protected void copyViewProperties(View src, View target) { for (ViewProperty viewProperty : src.getProperties()) { MetaProperty metaProperty = metaClass.getProperty(viewProperty.getName()); if (metaProperty == null || !metadata.getTools().isSystemLevel(metaProperty)) { if (!target.containsProperty(viewProperty.getName())) { target.addProperty(viewProperty.getName(), viewProperty.getView(), viewProperty.getFetchMode()); } } } } }
protected View createEmbeddedView(MetaClass metaPropertyClass) { View propView = viewRepository.getView(metaPropertyClass, View.BASE); View embeddedViewWithRelations = new View(propView, metaPropertyClass.getName() + ".entity-inspector-view", true); // iterate embedded properties and add relations with MINIMAL view for (MetaProperty embeddedNestedProperty : metaPropertyClass.getProperties()) { if (embeddedNestedProperty.getRange().isClass() && !embeddedNestedProperty.getRange().getCardinality().isMany()) { View embeddedRelationView = viewRepository.getView( embeddedNestedProperty.getRange().asClass(), View.MINIMAL); embeddedViewWithRelations.addProperty(embeddedNestedProperty.getName(), embeddedRelationView); } } return embeddedViewWithRelations; }
private void copyViewConsideringPermissions(View srcView, View dstView) { MetaClass metaClass = metadata.getClassNN(srcView.getEntityClass()); for (ViewProperty property : srcView.getProperties()) { if (security.isEntityAttrReadPermitted(metaClass, property.getName())) { View viewCopy = null; if (property.getView() != null) { viewCopy = new View(property.getView().getEntityClass(), property.getView().getName() + "(restricted)", false); copyViewConsideringPermissions(property.getView(), viewCopy); } dstView.addProperty(property.getName(), viewCopy, property.getFetchMode()); } } }
/** * Reload dynamic attributes on the entity */ @SuppressWarnings("unchecked") public void reloadDynamicAttributes(BaseGenericIdEntity entity) { MetaClass metaClass = entity.getMetaClass(); View view = new View(metaClass.getJavaClass(), false) .addProperty(metadata.getTools().getPrimaryKeyName(metaClass)); LoadContext loadContext = new LoadContext(metaClass) .setView(view) .setLoadDynamicAttributes(true) .setId(entity.getId()); BaseGenericIdEntity reloadedEntity = (BaseGenericIdEntity) dataManager.load(loadContext); if (reloadedEntity != null) { entity.setDynamicAttributes(reloadedEntity.getDynamicAttributes()); } } }