/** * Creates {@code InstanceContainer}. */ public <E extends Entity> InstanceContainer<E> createInstanceContainer(Class<E> entityClass) { return new InstanceContainerImpl<>(metadata.getClassNN(entityClass)); }
protected Set<Class> collectEntityClassesWithDynamicAttributes(@Nullable View view) { if (view == null) { return Collections.emptySet(); } return collectEntityClasses(view, new HashSet<>()).stream() .filter(BaseGenericIdEntity.class::isAssignableFrom) .filter(aClass -> !dynamicAttributesManagerAPI.getAttributesForMetaClass(metadata.getClassNN(aClass)).isEmpty()) .collect(Collectors.toSet()); }
protected List<String> getEffectiveEntities(String entitiesList) { List<String> effectiveEntities = new ArrayList<>(); if (StringUtils.isNotBlank(entitiesList)) { for (String className : Arrays.asList(StringUtils.split(entitiesList, ','))) { MetaClass clazz = metadata.getClassNN(className); effectiveEntities.add(extendedEntities.getEffectiveMetaClass(clazz).getName()); } } return effectiveEntities; }
protected MetaClass getMetaClassNN(RelatedEntitiesBuilder builder) { MetaClass metaClass = builder.getMetaClass(); if (metaClass == null) { Class entityClass = builder.getEntityClass(); if (entityClass == null) { throw new IllegalArgumentException("MetaClass or entityClass can't be null"); } else { metaClass = metadata.getClassNN(entityClass); } } return metaClass; }
/** * Determine whether the given class represents a persistent entity. * <p> * A persistent entity is an entity that is managed by ORM (i.e. registered in a persistence.xml file) * and is not a MappedSuperclass or Embeddable. */ public boolean isPersistent(Class aClass) { checkNotNullArgument(aClass, "class is null"); return isPersistent(metadata.getClassNN(aClass)); }
/** * Determine whether the given class represents a non-persistent entity. * <p> * A non-persistent entity is not managed by ORM (i.e. registered in a metadata.xml file). * <p> * Note that {@code isNotPersistent()} is not the same as {@code !isPersistent()}, because the latter does not * include MappedSuperclass and Embeddable entities that a still managed by ORM. */ public boolean isNotPersistent(Class aClass) { checkNotNullArgument(aClass, "class is null"); return isNotPersistent(metadata.getClassNN(aClass)); }
protected String getDataStore(String entityName) { if (!serverConfig.getUseEntityDataStoreForIdSequence()) { return Stores.MAIN; } else { return metadataTools.getStoreName(metadata.getClassNN(entityName)); } }
@Deprecated public Column(Class<T> entityClass, String propertyPath) { MetaClass metaClass = AppBeans.get(Metadata.class).getClassNN(entityClass); MetaPropertyPath mpp = metaClass.getPropertyPath(propertyPath); if (mpp == null) { throw new IllegalArgumentException(String.format("Unable to find %s in %s", propertyPath, entityClass)); } this.id = mpp; this.caption = AppBeans.get(MessageTools.class).getPropertyCaption(metaClass, propertyPath); this.type = mpp.getRangeJavaClass(); }
/** * @return list of related properties defined in {@link com.haulmont.chile.core.annotations.MetaProperty#related()} * or empty list */ public List<String> getRelatedProperties(Class<?> entityClass, String property) { checkNotNullArgument(entityClass, "entityClass is null"); MetaClass metaClass = metadata.getClassNN(entityClass); return getRelatedProperties(metaClass.getPropertyNN(property)); }
@Nullable @Override public LockInfo lock(Entity entity) { Preconditions.checkNotNullArgument(entity, "entity is null"); MetaClass metaClass = metadata.getClassNN(entity.getClass()); MetaClass originalMetaClass = metadata.getExtendedEntities().getOriginalOrThisMetaClass(metaClass); return lock(originalMetaClass.getName(), entity.getId().toString()); }
@Nullable @Override public <E extends Entity> E load(LoadContext<E> context) { MetaClass metaClass = metadata.getClassNN(context.getMetaClass()); DataStore storage = storeFactory.get(getStoreName(metaClass)); E entity = storage.load(context); if (entity != null) readCrossDataStoreReferences(Collections.singletonList(entity), context.getView(), metaClass, context.isJoinTransaction()); return entity; }
@Override public long getCount(LoadContext<? extends Entity> context) { MetaClass metaClass = metadata.getClassNN(context.getMetaClass()); DataStore storage = storeFactory.get(getStoreName(metaClass)); return storage.getCount(context); }
protected boolean needToFilterByInMemoryReadConstraints(LoadContext context) { return userSessionSource.getUserSession().hasConstraints() && security.hasInMemoryConstraints(metadata.getClassNN(context.getMetaClass()), ConstraintOperationType.READ, ConstraintOperationType.ALL); }
private String getCollectionString(Object collection) { if (DynamicAttributesUtils.isDynamicAttribute(propertyName)) { Metadata metadata = AppBeans.get(Metadata.class); com.haulmont.chile.core.model.MetaClass metaClass = metadata.getClassNN(metaClassName); MetaPropertyPath path = DynamicAttributesUtils.getMetaPropertyPath(metaClass, propertyName); return metadata.getTools().format(collection, path.getMetaProperty()); } return String.valueOf(beforeValue); }
@Override public void init(Map<String, Object> params) { parameterClass = metadata.getClassNN(PerformanceParameter.class); initJMXTable(); setNode(jmxConnectionField.getValue()); valuesTimer.setDelay(timerDelay); paramsTable.setShowItemsCountForGroup(false); }
public MultiplePermissionTarget(Class entityClass, String id, String caption, String permissionValue) { super(id, caption); Metadata metadata = AppBeans.get(Metadata.class); Messages messages = AppBeans.get(Messages.class); MetaClass metaclass = metadata.getClassNN(entityClass); this.entityMetaClass = metaclass; this.entityMetaClassName = metaclass.getName(); this.localName = messages.getTools().getEntityCaption(metaclass); this.entityClass = entityClass; this.caption = caption; this.permissionValue = permissionValue; }
public OperationPermissionTarget(Class entityClass, String id, String caption, String permissionValue) { super(id, caption); Metadata metadata = AppBeans.get(Metadata.class); Messages messages = AppBeans.get(Messages.class); MetaClass metaclass = metadata.getClassNN(entityClass); this.entityMetaClass = metaclass; this.entityMetaClassName = metaclass.getName(); this.localName = messages.getTools().getEntityCaption(metaclass); this.permissionValue = permissionValue; this.entityClass = entityClass; }
protected String getEntityName(Entity entity) { MetaClass metaClass; if (entity instanceof CategoryAttributeValue) { CategoryAttribute categoryAttribute = ((CategoryAttributeValue) entity).getCategoryAttribute(); Preconditions.checkNotNullArgument(categoryAttribute, "Category attribute is null"); metaClass = metadata.getClassNN(categoryAttribute.getCategoryEntityType()); } else { metaClass = metadata.getSession().getClassNN(entity.getClass()); } return metadata.getExtendedEntities().getOriginalOrThisMetaClass(metaClass).getName(); }
protected Report loadReportInternal(String entityId) { checkCanReadEntity(metadata.getClassNN(Report.class)); LoadContext<Report> loadContext = new LoadContext<>(Report.class); loadContext.setView(ReportService.MAIN_VIEW_NAME) .setQueryString("select r from report$Report r where r.id = :id and r.restAccess = true") .setParameter("id", getReportIdFromString(entityId)); reportSecurityManager.applySecurityPolicies(loadContext, null, userSessionSource.getUserSession().getCurrentOrSubstitutedUser()); Report report = dataManager.load(loadContext); checkEntityIsNotNull(metadata.getClassNN(Report.class).getName(), entityId, report); return report; }
private FetchGroupField createFetchGroupField(Class<? extends Entity> entityClass, FetchGroupField parentField, String property, FetchMode fetchMode) { MetaClass metaClass = metadata.getClassNN(entityClass); MetaProperty metaProperty = metaClass.getPropertyNN(property); MetaClass fetchMetaClass = metaProperty.getRange().isClass() ? metaProperty.getRange().asClass() : metaClass; return new FetchGroupField(metaClass, parentField, property, getFetchMode(fetchMetaClass, fetchMode), metadataTools.isCacheable(metaClass)); }