@Override public List<String> getValues(final Any<?> any, final VirSchema schema) { if (!anyUtilsFactory.getInstance(any).dao(). findAllowedSchemas(any, VirSchema.class).forSelfContains(schema)) { LOG.debug("{} not allowed for {}", schema, any); return Collections.emptyList(); } List<String> result = getValues(any, Collections.singleton(schema)).get(schema); return result == null ? Collections.emptyList() : result; }
append("FROM ").append(anyUtils().plainAttrClass().getSimpleName().substring(3)).append(" a, "). append(anyUtils().plainAttrValueClass().getSimpleName().substring(3)).append(" v, "). append(PlainSchema.class.getSimpleName()).append(" s "). append("WHERE ").append(clause);
@Override public Map<AnyType, Integer> countByType() { Query query = entityManager().createQuery( "SELECT e.type, COUNT(e) AS countByType FROM " + anyUtils().anyClass().getSimpleName() + " e " + "GROUP BY e.type ORDER BY countByType DESC"); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); Map<AnyType, Integer> countByRealm = new LinkedHashMap<>(results.size()); for (Object[] result : results) { countByRealm.put((AnyType) result[0], ((Number) result[1]).intValue()); } return Collections.unmodifiableMap(countByRealm); }
switch (intAttrName.getField()) { case "key": Any<?> any = anyUtils.dao().find(connObjectKey); if (any != null) { result.add(any.getKey()); switch (intAttrName.getSchemaType()) { case PLAIN: PlainAttrValue value = anyUtils.newPlainAttrValue(); result.addAll(anyUtils.dao().findByPlainAttrValue( intAttrName.getSchemaName(), value, provision.isIgnoreCaseMatch()). stream().map(Entity::getKey).collect(Collectors.toList())); result.addAll(anyUtils.dao().findByDerAttrValue( intAttrName.getSchemaName(), connObjectKey, provision.isIgnoreCaseMatch()). stream().map(Entity::getKey).collect(Collectors.toList()));
Field anyField = anyUtils.getField(computed.getSchema()); if (anyField == null) { LOG.warn("Ignoring invalid field '{}'", computed.getSchema()); PlainAttrValue attrValue = anyUtils.newPlainAttrValue(); if (computed.getType() != AttributeCond.Type.LIKE && computed.getType() != AttributeCond.Type.ILIKE
@Override public void add(final String value, final AnyUtils anyUtils) { checkNonNullSchema(); PlainAttrValue attrValue; if (getSchema().isUniqueConstraint()) { attrValue = anyUtils.newPlainAttrUniqueValue(); ((PlainAttrUniqueValue) attrValue).setSchema(getSchema()); } else { attrValue = anyUtils.newPlainAttrValue(); } add(value, attrValue); }
AnyUtils anyUtils = anyUtilsFactory.getInstance(reference); if (intAttrName.getField() != null) { PlainAttrValue attrValue = anyUtils.newPlainAttrValue(); } else { if (attr.getUniqueValue() != null) { values.add(anyUtils.clonePlainAttrValue(attr.getUniqueValue())); } else if (attr.getValues() != null) { attr.getValues().forEach(value -> values.add(anyUtils.clonePlainAttrValue(value))); : derAttrHandler.getValue(reference, membership, derSchema); if (derValue != null) { PlainAttrValue attrValue = anyUtils.newPlainAttrValue(); attrValue.setStringValue(derValue); values.add(attrValue); : virAttrHandler.getValues(reference, membership, virSchema); virValues.forEach(virValue -> { PlainAttrValue attrValue = anyUtils.newPlainAttrValue(); attrValue.setStringValue(virValue); values.add(attrValue); flatMap(role -> role.getPrivileges(application).stream()). forEach(privilege -> { PlainAttrValue attrValue = anyUtils.newPlainAttrValue(); attrValue.setStringValue(privilege.getKey()); values.add(attrValue);
protected void deleteAttrs(final PlainSchema schema) { for (AnyTypeKind anyTypeKind : AnyTypeKind.values()) { AnyUtils anyUtils = anyUtilsFactory.getInstance(anyTypeKind); findAttrs(schema, anyUtils.plainAttrClass()).forEach(attr -> { plainAttrDAO.delete(attr); }); } }
@Override public AnyTO get() { return template == null ? anyType == null ? null : ApplicationContextProvider.getApplicationContext().getBean(AnyUtilsFactory.class). getInstance(anyType.getKind()).newAnyTO() : anyType == null ? null : POJOHelper.deserialize(template, anyType.getKind().getTOClass()); }
private void setFieldOrSchemaName( final String fieldOrSchemaName, final AnyTypeKind anyTypeKind, final IntAttrName result) { if (anyUtilsFactory.getInstance(anyTypeKind).getField(fieldOrSchemaName) == null) { result.setSchemaType(find(fieldOrSchemaName)); result.setSchemaName(fieldOrSchemaName); } else { result.setField(fieldOrSchemaName); } }
if (provision.getUidOnCreate() != null) { anyUtilsFactory.getInstance(task.getAnyTypeKind()). addAttr(task.getEntityKey(), provision.getUidOnCreate(), result.getUidValue());
protected Pair<PlainSchema, PlainAttrValue> check(final AttributeCond cond, final AnyTypeKind kind) { AnyUtils anyUtils = anyUtilsFactory.getInstance(kind); PlainSchema schema = schemaDAO.find(cond.getSchema()); if (schema == null) { LOG.warn("Ignoring invalid schema '{}'", cond.getSchema()); throw new IllegalArgumentException(); } PlainAttrValue attrValue = schema.isUniqueConstraint() ? anyUtils.newPlainAttrUniqueValue() : anyUtils.newPlainAttrValue(); try { if (cond.getType() != AttributeCond.Type.LIKE && cond.getType() != AttributeCond.Type.ILIKE && cond.getType() != AttributeCond.Type.ISNULL && cond.getType() != AttributeCond.Type.ISNOTNULL) { ((JPAPlainSchema) schema).validator().validate(cond.getExpression(), attrValue); } } catch (ValidationException e) { LOG.error("Could not validate expression '" + cond.getExpression() + "'", e); throw new IllegalArgumentException(); } return Pair.of(schema, attrValue); }
@Override public PlainSchema update(final PlainSchemaTO schemaTO, final PlainSchema schema) { SyncopeClientCompositeException scce = SyncopeClientException.buildComposite(); boolean hasAttrs = false; for (AnyTypeKind anyTypeKind : AnyTypeKind.values()) { AnyUtils anyUtils = anyUtilsFactory.getInstance(anyTypeKind); hasAttrs |= plainSchemaDAO.findAttrs(schema, anyUtils.plainAttrClass()).isEmpty(); } if (hasAttrs) { if (schema.getType() != schemaTO.getType()) { SyncopeClientException e = SyncopeClientException.build(ClientExceptionType.InvalidPlainSchema); e.getElements().add("Cannot change type since " + schema.getKey() + " has attributes"); scce.addException(e); } if (schema.isUniqueConstraint() != schemaTO.isUniqueConstraint()) { SyncopeClientException e = SyncopeClientException.build(ClientExceptionType.InvalidPlainSchema); e.getElements().add("Cannot alter unique contraint since " + schema.getKey() + " has attributes"); scce.addException(e); } } if (scce.hasExceptions()) { throw scce; } return fill(schema, schemaTO); }
private <T extends AnyTO> T getAnyTOFromConnObject( final ConnectorObject obj, final PullTask pullTask, final Provision provision, final AnyUtils anyUtils) { T anyTO = anyUtils.newAnyTO(); anyTO.setType(provision.getAnyType().getKey()); // 1. fill with data from connector object anyTO.setRealm(pullTask.getDestinatioRealm().getFullPath()); MappingUtils.getPullItems(provision.getMapping().getItems()).forEach(item -> { mappingManager.setIntValues(item, obj.getAttributeByName(item.getExtAttrName()), anyTO); }); // 2. add data from defined template (if any) templateUtils.apply(anyTO, pullTask.getTemplate(provision.getAnyType())); return anyTO; } }
OrderBySupport.Item item = new OrderBySupport.Item(); if (anyUtils.getField(clause.getField()) == null) { PlainSchema schema = schemaDAO.find(clause.getField()); if (schema != null) {
&& result.getOperation() == ResourceOperation.CREATE). forEach(result -> { anyUtils.addAttr(result.getKey(), provision.getUidOnCreate(), result.getUidValue()); });
@Override public List<String> getValues(final Any<?> any, final Membership<?> membership, final VirSchema schema) { if (!anyUtilsFactory.getInstance(any).dao(). findAllowedSchemas(any, VirSchema.class).getForMembership(membership.getRightEnd()).contains(schema)) { LOG.debug("{} not allowed for {}", schema, any); return Collections.emptyList(); } List<String> result = getValues(any, Collections.singleton(schema)).get(schema); return result == null ? Collections.emptyList() : result; }
@Override public Map<String, Integer> countByStatus() { Query query = entityManager().createQuery( "SELECT e.status, COUNT(e) FROM " + anyUtils().anyClass().getSimpleName() + " e GROUP BY e.status"); @SuppressWarnings("unchecked") List<Object[]> results = query.getResultList(); return results.stream().collect(Collectors.toMap( result -> (String) result[0], result -> ((Number) result[1]).intValue())); }
@Override public String getValue(final Any<?> any, final DerSchema schema) { if (!anyUtilsFactory.getInstance(any).dao(). findAllowedSchemas(any, DerSchema.class).forSelfContains(schema)) { LOG.debug("{} not allowed for {}", schema, any); return null; } return getValues(any, Collections.singleton(schema)).get(schema); }
@Override public int count() { Query query = entityManager().createQuery( "SELECT COUNT(e) FROM " + anyUtils().anyClass().getSimpleName() + " e"); return ((Number) query.getSingleResult()).intValue(); }