Gets the PermissionSet.

@param _instance the instance
@param _evaluate the evaluate
@return the PermissionSet
@throws EFapsException on error
976896
public static PermissionSet getPermissionSet(final Instance _instance,
                                                 final boolean _evaluate)
        throws EFapsException
    {
        Evaluation.LOG.debug("Retrieving PermissionSet for {}", _instance);
        final Key accessKey = Key.get4Instance(_instance);
        final PermissionSet ret;
        if (AccessCache.getPermissionCache().containsKey(accessKey)) {
            ret = AccessCache.getPermissionCache().get(accessKey);
        } else if (_evaluate) {
            ret = new PermissionSet().setPersonId(accessKey.getPersonId()).setCompanyId(accessKey.getCompanyId())
                            .setTypeId(accessKey.getTypeId());
            Evaluation.eval(ret);
            AccessCache.getPermissionCache().put(accessKey, ret);
        } else {
            ret = null;
        }
        Evaluation.LOG.debug("Retrieved PermissionSet {}", ret);
        return ret;
    }
1174878
def get_permission_object(self):
        
        if not isinstance(self, BaseCreateView):
            # We do NOT want to call get_object in a BaseCreateView, see issue #85
            if hasattr(self, 'get_object') and callable(self.get_object):
                # Requires SingleObjectMixin or equivalent ``get_object`` method
                return self.get_object()
        return None
689671
public Set<Classification> getClassifiedByTypes()
        throws EFapsException
    {
        if (!this.checked4classifiedBy) {
            final QueryBuilder attrQueryBldr = new QueryBuilder(CIAdminDataModel.TypeClassifies);
            attrQueryBldr.addWhereAttrEqValue(CIAdminDataModel.TypeClassifies.To, getId());
            final AttributeQuery attrQuery = attrQueryBldr.getAttributeQuery(CIAdminDataModel.TypeClassifies.From);
            final QueryBuilder queryBldr = new QueryBuilder(CIAdminDataModel.Type);
            queryBldr.addWhereAttrInQuery(CIAdminDataModel.Type.ID, attrQuery);
            final InstanceQuery query = queryBldr.getQuery();
            query.executeWithoutAccessCheck();
            while (query.next()) {
                Type.get(query.getCurrentValue().getId());
            }
            this.checked4classifiedBy = true;
            setDirty();
        }
        final Set<Classification> ret = new HashSet<>();
        if (getParentType() != null) {
            ret.addAll(getParentType().getClassifiedByTypes());
        }
        for (final Long id : this.classifiedByTypes) {
            ret.add((Classification) Type.get(id));
        }
        return Collections.unmodifiableSet(ret);
    }
1007956
def object_permission_set(self):
        '''
        
        '''
        return Or(
            AllowAdmin,
            AllowObjectPermission('team:admin'),
            AllowObjectPermission('org:admin', lambda t: t.organization_id),
            And(
                AllowOnlySafeHttpMethod,
                Or(
                    ObjAttrTrue(
                        lambda r, t: t.users.filter(pk=r.user.pk).exists()),
                    ObjAttrTrue(
                        lambda r, t: t.organization.users.filter(
                            pk=r.user.pk).exists())
                )
            )
        )
644129
@SuppressWarnings("unchecked")
    public List<Instance> getInstances()
        throws EFapsException
    {
        final List<Instance> ret = new ArrayList<>();
        // no value select means, that the from select must be asked
        if (this.valueSelect == null) {
            ret.addAll(this.fromSelect.getMainOneSelect().getInstances());
        } else {
            // if an oid select was given the oid is evaluated
            if ("oid".equals(this.valueSelect.getValueType())) {
                for (final Object object : this.objectList) {
                    final Instance inst = Instance.get((String) this.valueSelect.getValue(object));
                    if (inst.isValid()) {
                        ret.add(inst);
                    }
                }
            } else {
                final List<Long> idTmp;
                if (this.valueSelect.getParentSelectPart() != null
                                && this.valueSelect.getParentSelectPart() instanceof LinkToSelectPart) {
                    idTmp = (List<Long>) this.valueSelect.getParentSelectPart().getObject();
                } else {
                    idTmp = this.idList;
                }
                for (final Long id : idTmp) {
                    if (id != null) {
                        ret.add(Instance.get(this.valueSelect.getAttribute().getParent(), String.valueOf(id)));
                    }
                }
            }
        }
        return ret;
    }
343021
@SuppressWarnings("unchecked")
    public <T> T getAttribute(final Attribute _attribute)
        throws EFapsException
    {
        return (T) getAttribute(_attribute.getName());
    }
1186050
public static List<IndexDefinition> get()
        throws EFapsException
    {
        final List<IndexDefinition> ret = new ArrayList<>();

        final QueryBuilder queryBldr = new QueryBuilder(CIAdminIndex.IndexDefinition);
        final MultiPrintQuery multi = queryBldr.getPrint();
        final SelectBuilder selUUID = SelectBuilder.get().linkto(CIAdminIndex.IndexDefinition.TypeLink)
                        .attribute(CIAdminDataModel.Type.UUID);
        multi.addSelect(selUUID);
        multi.execute();
        while (multi.next()) {
            final UUID uuidTmp = UUID.fromString(multi.getSelect(selUUID));
            final Set<Type> types = getChildTypes(Type.get(uuidTmp));
            for (final Type type : types) {
                final IndexDefinition indexDef = IndexDefinition.get(type.getUUID());
                if (!type.isAbstract()) {
                    ret.add(indexDef);
                }
            }
        }
        return ret;
    }
150911
private void getValues4Instances(final String _oid)
        throws EFapsException
    {
        // group the instance by type
        // check if the current instance is the list (happens if this
        // value select is e.g. part of a linkto
        final Map<Type, List<Instance>> type2instance = new HashMap<>();
        final Instance currentInst = Instance.get(_oid);
        final List<Instance> instances = new ArrayList<>();
        if (getOneSelect().getQuery().getInstanceList().contains(currentInst)) {
            instances.addAll(getOneSelect().getQuery().getInstanceList());
        } else {
            for (final Object object : getOneSelect().getObjectList()) {
                final String oid =  (String) super.getValue(object);
                instances.add(Instance.get(oid));
            }
        }

        for (final Instance instance : instances) {
            final List<Instance> tmpList;
            if (type2instance.containsKey(instance.getType())) {
                tmpList = type2instance.get(instance.getType());
            } else {
                tmpList = new ArrayList<>();
                type2instance.put(instance.getType(), tmpList);
            }
            tmpList.add(instance);
        }

        // make one union part for every type
        for (final Entry<Type, List<Instance>> entry : type2instance.entrySet()) {

            boolean union = false;
            final Set<Classification> classTypes = new HashSet<>();
            Type curr = entry.getKey();
            while (curr.getParentType() != null) {
                classTypes.addAll(curr.getClassifiedByTypes());
                curr = curr.getParentType();
            }
            classTypes.addAll(curr.getClassifiedByTypes());
            final SQLSelect unionSelect = new SQLSelect();
            for (final Classification clazz : classTypes) {

                final Attribute typeAttr = clazz.getClassifyRelationType()
                                .getAttribute(clazz.getRelTypeAttributeName());
                final Attribute linkAttr = clazz.getClassifyRelationType()
                                .getAttribute(clazz.getRelLinkAttributeName());
                final SQLSelect select;
                if (union) {
                    unionSelect.addPart(SQLPart.UNION).addPart(SQLPart.ALL);
                    select = new SQLSelect();
                } else {
                    select = unionSelect;
                    union = true;
                }
                select.column(0, "ID")
                    .column(0, linkAttr.getSqlColNames().get(0))
                    .column(0, typeAttr.getSqlColNames().get(0))
                    .from(clazz.getClassifyRelationType().getMainTable().getSqlTable(), 0)
                    .addPart(SQLPart.WHERE)
                    .addColumnPart(0, linkAttr.getSqlColNames().get(0))
                    .addPart(SQLPart.IN).addPart(SQLPart.PARENTHESIS_OPEN);

                boolean first = true;
                for (final Instance instance : entry.getValue()) {
                    if (first) {
                        first = false;
                    } else {
                        select.addPart(SQLPart.COMMA);
                    }
                    select.addValuePart(instance.getId());
                }
                select.addPart(SQLPart.PARENTHESIS_CLOSE);
                if (clazz.getClassifyRelationType().getMainTable().getSqlColType() != null) {
                    select.addPart(SQLPart.AND)
                        .addColumnPart(0, clazz.getClassifyRelationType().getMainTable().getSqlColType())
                        .addPart(SQLPart.EQUAL).addValuePart(clazz.getClassifyRelationType().getId());
                }
                if (union && !select.equals(unionSelect)) {
                    unionSelect.addNestedSelectPart(select.getSQL());
                }
            }
            if (classTypes.size() > 0) {
                executeOneCompleteStmt(unionSelect.getSQL(), entry.getValue());
            }
        }
    }
236575
public static Context begin(final String _userName,
                                final Inheritance _inheritance)
        throws EFapsException
    {
        return Context.begin(_userName, null, null, null, null, _inheritance);
    }
987161
public String checkAccess (Permission perm, Object context)
    {
        if (_permPolicy == null) {
            _permPolicy = createPermissionPolicy();
        }
        return _permPolicy.checkAccess(perm, context);
    }
112023
protected List<Boolean> access(final Select _select)
        throws EFapsException
    {
        List<Boolean> ret = new ArrayList<>();
        // remove the IAuxillary to determine the size
        int size = _select.getElements().size();
        while (_select.getElements().get(size - 1) instanceof IAuxillary) {
            size--;
        }
        if (size == 1) {
            ret.add(this.access.hasAccess(inst()));
        } else {
            int idx = 0;
            boolean accessTemp = true;
            while (idx < size && accessTemp) {
                final AbstractElement<?> element = _select.getElements().get(idx);
                idx++;
                final Select instSelect = this.selection.getInstSelects().get(element.getPath());
                if (element instanceof AttributeSetElement) {
                    idx = size;
                    if (instSelect.getCurrent() != null && instSelect.getCurrent() instanceof Collection) {
                        ret = Collections.nCopies(((Collection<?>) instSelect.getCurrent()).size(), true);
                    }
                } else {
                    if (instSelect == null) {
                        LOG.error("Could not retrieve Instance Select for Path {}", element.getPath());
                    }
                    final Object obj = instSelect.getCurrent();
                    if (obj instanceof Instance) {
                        accessTemp = this.access.hasAccess((Instance) obj);
                        ret.clear();
                        ret.add(accessTemp);
                    } else if (obj instanceof List) {
                        if (ret.isEmpty()) {
                            ret = ((List<?>) obj).stream()
                                            .map(ele -> this.access.hasAccess((Instance) ele))
                                            .collect(Collectors.toList());
                        } else {
                            final Iterator<Boolean> iter = ret.iterator();
                            ret = ((List<?>) obj).stream()
                                            .map(ele -> iter.next() && this.access.hasAccess((Instance) ele))
                                            .collect(Collectors.toList());
                        }
                        accessTemp = ret.contains(true);
                    }
                }
            }
        }
        return ret;
    }
1099627
public static void evalStatus(final Collection<Instance> _instances)
        throws EFapsException
    {
        Evaluation.LOG.debug("Evaluating Status for {}", _instances);
        if (CollectionUtils.isNotEmpty(_instances)) {
            final Cache<String, Long> cache = AccessCache.getStatusCache();
            final List<Instance> instances = _instances.stream().filter(inst -> !cache.containsKey(inst.getKey()))
                            .collect(Collectors.toList());
            if (!instances.isEmpty()) {
                final Attribute attr = instances.get(0).getType().getStatusAttribute();
                final MultiPrintQuery multi = new MultiPrintQuery(instances);
                multi.addAttribute(attr);
                multi.executeWithoutAccessCheck();
                while (multi.next()) {
                    final Long statusId = multi.getAttribute(attr);
                    cache.put(multi.getCurrentInstance().getKey(), statusId == null ? 0 : statusId);
                }
            }
        }
    }
1174637
@Override
    public Collection<Permission> getAllPermissionsFromPermissionSet(String permissionSet)
        throws PermissionSetNotFoundException {
        Collection<Permission> result = new HashSet<Permission>();
        for (String s : getAllPermissionSetsFromPermissionSet(permissionSet)) {
            result.addAll(getPermissionsFromPermissionSet(s));
        }
        return result;
    }
865740
public static void index(final List<Instance> _instances)
        throws EFapsException
    {
        Indexer.index(new IndexContext().setAnalyzer(Index.getAnalyzer()).setDirectory(Index.getDirectory())
                        .setLanguage(Context.getThreadContext().getLanguage())
                        .setCompanyId(Context.getThreadContext().getCompany().getId()), _instances);
    }
888851
@Override
    public Object getValue(final Object _object)
        throws EFapsException
    {
        final Instance inst = (Instance) super.getValue(_object);
        if (this.esjp == null) {
            try {
                final Class<?> clazz = Class.forName(this.className, false, EFapsClassLoader.getInstance());
                this.esjp = (IEsjpSelect) clazz.newInstance();
                final List<Instance> instances = new ArrayList<>();
                for (final Object obj : getOneSelect().getObjectList()) {
                    instances.add((Instance) super.getValue(obj));
                }
                if (this.parameters.isEmpty()) {
                    this.esjp.initialize(instances);
                } else {
                    this.esjp.initialize(instances, this.parameters.toArray(new String[this.parameters.size()]));
                }
            } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                LOG.error("Catched error", e);
            }
        }
        return this.esjp.getValue(inst);
    }
149653
public <T> T getAttribute(final CIAttribute _attribute)
        throws EFapsException
    {
        return this.<T>getAttribute(_attribute.name);
    }
1306902
public <T> T get(final CIAttribute _ciAttr)
        throws EFapsException
    {
        return get(Print.getDefaultAlias(_ciAttr));
    }