public static <T> Collection<SelectorOptions<T>> createCollection(UniformItemPath path, T options) { Collection<SelectorOptions<T>> optionsCollection = new ArrayList<>(1); optionsCollection.add(create(path, options)); return optionsCollection; }
public static Collection<SelectorOptions<GetOperationOptions>> fromRestOptions(List<String> options, List<String> include, List<String> exclude, DefinitionProcessingOption definitionProcessing, PrismContext prismContext) { if (CollectionUtils.isEmpty(options) && CollectionUtils.isEmpty(include) && CollectionUtils.isEmpty(exclude)) { if (definitionProcessing != null) { return SelectorOptions.createCollection(GetOperationOptions.createDefinitionProcessing(definitionProcessing)); } return null; } Collection<SelectorOptions<GetOperationOptions>> rv = new ArrayList<>(); GetOperationOptions rootOptions = fromRestOptions(options, definitionProcessing); if (rootOptions != null) { rv.add(SelectorOptions.create(rootOptions)); } for (ItemPath includePath : ItemPathCollectionsUtil.pathListFromStrings(include, prismContext)) { rv.add(SelectorOptions.create(prismContext.toUniformPath(includePath), GetOperationOptions.createRetrieve())); } for (ItemPath excludePath : ItemPathCollectionsUtil.pathListFromStrings(exclude, prismContext)) { rv.add(SelectorOptions.create(prismContext.toUniformPath(excludePath), GetOperationOptions.createDontRetrieve())); } // Do NOT set executionPhase here! return rv; }
public Collection<SelectorOptions<GetOperationOptions>> createGetOptions(SelectorQualifiedGetOptionsType optionsBean, boolean noFetch) { LOGGER.trace("optionsBean = {}, noFetch = {}", optionsBean, noFetch); Collection<SelectorOptions<GetOperationOptions>> rv = MiscSchemaUtil.optionsTypeToOptions(optionsBean, prismContext); if (noFetch) { if (rv == null) { return SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); } GetOperationOptions root = SelectorOptions.findRootOptions(rv); if (root != null) { root.setNoFetch(true); } else { rv.add(SelectorOptions.create(GetOperationOptions.createNoFetch())); } } return rv; }
public static <T> Collection<SelectorOptions<T>> createCollection(T options, UniformItemPath... paths) { Collection<SelectorOptions<T>> optionsCollection = new ArrayList<>(paths.length); for (UniformItemPath path: paths) { optionsCollection.add(create(path, options)); } return optionsCollection; }
options.add(SelectorOptions.create(GetOperationOptions.createNoFetch()));
@Deprecated // use GetOperationOptionsBuilder public static <T> Collection<SelectorOptions<T>> set(Collection<SelectorOptions<T>> options, UniformItemPath path, Supplier<T> constructor, Consumer<T> setter) { if (options == null) { options = new ArrayList<>(); } Collection<T> optionsForPath = findOptionsForPath(options, path); T option; if (optionsForPath.isEmpty()) { option = constructor.get(); options.add(SelectorOptions.create(path, option)); } else { option = optionsForPath.iterator().next(); } setter.accept(option); return options; } //endregion
@Override protected void extendOptions(Collection<SelectorOptions<GetOperationOptions>> options, boolean searchOnResource) { super.extendOptions(options, searchOnResource); // We do not need to worry about associations of associations here // (nested associations). Avoiding that will make the query faster. options.add(SelectorOptions.create(getPrismContext().toUniformPath(ShadowType.F_ASSOCIATION), GetOperationOptions.createDontRetrieve())); }
private void applyAttributesToGet(LensProjectionContext projCtx, Collection<SelectorOptions<GetOperationOptions>> options) throws SchemaException { if ( !LensUtil.isPasswordReturnedByDefault(projCtx) && LensUtil.needsFullShadowForCredentialProcessing(projCtx)) { options.add(SelectorOptions.create(prismContext.toUniformPath(SchemaConstants.PATH_PASSWORD_VALUE), GetOperationOptions.createRetrieve())); } }
readOptions.add(SelectorOptions.create(GetOperationOptions.createAllowNotFound())); } else { root.setAllowNotFound(true);
private PrismObject<LookupTableType> getFullTable(String oid, OperationResult result) throws ObjectNotFoundException, SchemaException { SelectorOptions<GetOperationOptions> retrieve = SelectorOptions.create(prismContext.toUniformPath(F_ROW), GetOperationOptions.createRetrieve(INCLUDE)); return repositoryService.getObject(LookupTableType.class, oid, Arrays.asList(retrieve), result); }
private void checkTable(String tableOid, PrismObject<LookupTableType> expectedObject, OperationResult result) throws SchemaException, ObjectNotFoundException { SelectorOptions<GetOperationOptions> retrieve = SelectorOptions.create(prismContext.toUniformPath(F_ROW), GetOperationOptions.createRetrieve(INCLUDE)); PrismObject<LookupTableType> table = repositoryService.getObject(LookupTableType.class, tableOid, Arrays.asList(retrieve), result); expectedObject.setOid(tableOid); PrismAsserts.assertEquivalent("Table is not as expected", expectedObject, table); }
private void checkObject(String oid, PrismObject<UserType> expected, boolean loadPhoto, OperationResult result) throws ObjectNotFoundException, SchemaException { Collection<SelectorOptions<GetOperationOptions>> options; if (loadPhoto) { options = Collections.singletonList( SelectorOptions.create(prismContext.toUniformPath(UserType.F_JPEG_PHOTO), GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE))); } else { options = null; } PrismObject<UserType> real = repositoryService.getObject(UserType.class, oid, options, result); ObjectDelta<UserType> delta = expected.diff(real); System.out.println("Expected object = \n" + expected.debugDump()); System.out.println("Real object in repo = \n" + real.debugDump()); System.out.println("Difference = \n" + delta.debugDump()); if (!delta.isEmpty()) { fail("Objects are not equal.\n*** Expected:\n" + expected.debugDump() + "\n*** Got:\n" + real.debugDump() + "\n*** Delta:\n" + delta.debugDump()); } }
private void checkObject(String oid, PrismObject<OrgType> expected, boolean loadPhoto, OperationResult result) throws ObjectNotFoundException, SchemaException { Collection<SelectorOptions<GetOperationOptions>> options; if (loadPhoto) { options = Collections.singletonList( SelectorOptions.create(prismContext.toUniformPath(FocusType.F_JPEG_PHOTO), GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE))); } else { options = null; } PrismObject<OrgType> real = repositoryService.getObject(OrgType.class, oid, options, result); ObjectDelta<OrgType> delta = expected.diff(real); System.out.println("Expected object = \n" + expected.debugDump()); System.out.println("Real object in repo = \n" + real.debugDump()); System.out.println("Difference = \n" + delta.debugDump()); if (!delta.isEmpty()) { fail("Objects are not equal.\n*** Expected:\n" + expected.debugDump() + "\n*** Got:\n" + real.debugDump() + "\n*** Delta:\n" + delta.debugDump()); } }