protected void reloadProcTask() { View view = new View(ProcTask.class) .addProperty("actExecutionId"); procTask = dataManager.reload(procTask, view); }
protected View deserializeView(JsonObject jsonObject) { String viewName = jsonObject.getAsJsonPrimitive("name").getAsString(); String entityName = jsonObject.getAsJsonPrimitive("entity").getAsString(); JsonArray properties = jsonObject.getAsJsonArray("properties"); MetaClass metaClass = metadata.getClass(entityName); if (metaClass == null) { throw new ViewSerializationException(String.format("Entity with name %s not found", entityName)); } View view = new View(metaClass.getJavaClass(), viewName, false); fillViewProperties(view, properties, metaClass); return view; }
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(); }
/** * 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 getView(MetaClass metaClass) { View localView = viewRepository.getView(metaClass, View.LOCAL); View minimalView = viewRepository.getView(metaClass, View.MINIMAL); View view = new View(localView.getEntityClass(), "entitiesView", false); copyViewProperties(localView, view, metaClass); copyViewProperties(minimalView, view, metaClass); return view; }
protected void initView() { View localView = viewRepository.getView(metaClass, View.LOCAL); View minimalView = viewRepository.getView(metaClass, View.MINIMAL); view = new View(localView.getEntityClass(), "entitiesView", false); copyViewProperties(localView, view); copyViewProperties(minimalView, 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); }
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); }
/** * Removes restricted attributes from a view. * * @param view source view * @return restricted view */ public View createRestrictedView(View view) { if (!config.getEntityAttributePermissionChecking()) { return view; } Preconditions.checkNotNullArgument(view, "view is null"); View restrictedView = new View(view.getEntityClass(), StringUtils.isEmpty(view.getName()) ? "" : view.getName() + "_restricted", false); // do not include system properties in constructor because they will be copied later if exist copyViewConsideringPermissions(view, restrictedView); return restrictedView; }
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 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 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 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 Entity reloadInstance(Entity instance) { View reloadView = new View(instance.getMetaClass().getJavaClass(), true); LoadContext loadContext = new LoadContext(instance.getMetaClass()); loadContext.setSoftDeletion(false); loadContext.setId(instance.getId()); loadContext.setView(reloadView); DataSupplier supplier = getDataSupplier(); return supplier.load(loadContext); }
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()); } } }
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; }