Search User based on Custom attribute value in OIM - java

I have created one custom attribute and updating its value to 'true'. Now I am trying to fetch all the user for which custom attribute value is 'true'. I am trying to use the below API but in that I am able to pass only OOTB attributes. Please help.
List listOfStatus = new ArrayList();
listOfStatus.add("true");
SearchCriteria statusSearchCriteria = new SearchCriteria(UserManagerConstants.AttributeValues.USER_STATUS_ACTIVE.getId(), listOfStatus, SearchCriteria.Operator.IN);

You'd need to mark the attribute as "Searchable" to be able to search against it. In the API you will provide then this attribute name.

Related

Is it possible to retrieve the entire list of named AnnotationSets in GATE?

is it possible to retrieve the entire list of an Annotation Set in GATE? This line of code returns all the items of a GATE document that belong to the AnnotationSet called "EMail";
AnnotationSet annSet = doc.getAnnotations().get("EMail");
Now, how can I know all of the Annotations' Set names instead of the only "EMail"?
Isn't this the answer to your question:
AnnotationSet annSet = doc.getAnnotations();
I think you mix two different terms: annotation set and annotation type. Be careful about these two...
There are several methods of gate.Document and gate.AnnotationSet that can be used:
gate.Document.getAnnotations() ... all annotations from the default (without name) annotation set.
gate.Document.getAnnotations(String setName)... all annotations from named annotation set with name setName.
gate.AnnotationSet.get(String anntoationType)... select only annotations with given anntoationType.
gate.Document.getAnnotationSetNames()... get all the names of named annotation sets in a document
gate.AnnotationSet.getAllTypes()... get set of all annotation type names of annotations present in given annotation set.
See more details in javadoc:
SimpleAnnotationSet
SimpleDocument
Document doc;
// create/manipulate the document...
Set<String> names = doc.getAnnotationSetNames();
Map<String, AnnotationSet> namedAnnSets = doc.getNamedAnnotationSets();
// The default AS always exists
AnnotationSet defaultAS = doc.getAnnotations();
Note that a GATE document always has a default (unnamed) annotation set, which is not included in the set of names or map of named sets.

Binding a JavaFx ListView's selection index to an integer property

Is it possible to bind (one-way) a ListView's selection index or item to a property?
I can get a ReadOnlyIntegerProperty with this call, but it's a ReadOnlyProperty which does not have the bind methods you see in ObjectProperty, StringProperty, etc.
myListView.getSelectionModel().selectedIndexProperty()
How do I go about binding an Integer Property to my ListView's selected index property?
The API exposes the selectedIndex as a ReadOnlyProperty because it doesn't want to expose the bind method that is part of the Property API. The reason it doesn't want to expose the bind method is that the ListView needs to be able to set the property when the user clicks on it. If the bind method were part of the API, and the programmer called listView.getSelectionModel().selectedIndexProperty().bind(...), then runtime errors would be generated whenever the user clicked on the list.
Because the bindBidirectional is also part of the Property API, but not the ReadOnlyProperty API, this means that you also cannot bidirectionally bind the selectedIndex.
You can achieve the same effect as bidirectional binding using two listeners:
IntegerProperty property = new SimpleIntegerProperty();
ListView<?> listView = new ListView<?>();
// change property when selection changes:
listView.getSelectionModel().selectedIndexProperty().addListener((obs, oldIndex, newIndex) ->
property.set(newIndex.intValue()));
// change selection when property changes:
property.addListener((obs, oldValue, newValue) ->
listView.getSelectionModel().clearAndSelect(newValue.intValue()));
If you just want to bind the selected item index to the property, you only need the second listener.
If you just want to bind the property to the selected item index, and you are not going to set the property by other means, then of course you can just bind the property:
IntegerProperty property = new SimpleIntegerProperty();
property.bind(listView.getSelectionModel().selectedIndexProperty());
(Though in this case, you could always just reference the selectedIndexProperty directly if your design allows.)
I can understnad not permitting biDirectionalBinding since it's read
only, but how can i do one way binding?
Try:
IntegerProperty property = new SimpleIntegerProperty();
property.bind(myListView.getSelectionModel().selectedIndexProperty());

Saving Object with path in Spring MVC

I yould like to know if it is possible to directly save an object in a hibernate/spring/maven project with path. So my class has an object attribute "Category". In the form I have a select. If I put different Category objects as Value in select and I link the select with form:select and path to the Category attribute, will it save it automatically ? Otherwise I would have to get the ID, get back the object from the ID in my controller and then set the Category attribute with the setter in order to save the whole thing.
Thanks

hasErrors(): how to ignoring validation of specific input

I have a User class with many variables (name, email, password, etc) and sometimes I need to update only one or two of them (using a form). I get the data from the form and use bind of a json object:
Form<User> userForm = User.form.bind(json);
if(userForm.hasErrors()) {
return badRequest("error");
}
hasError() retrieves error because it doesn't receive some data. How can I tell to hasError() that it have not to validate some specific fields?
Take a look at the "Forms" sample app on GitHub. It shows how to assign a "group" to your constraints such that you can enforce a different set of constraints depending on the situation. The projects I'v worked on are still on Play 2.0.x which didn't have this, but I believe it is in Play 2.1 and/or 2.2.
https://github.com/playframework/playframework/tree/master/samples/java/forms
The files you want to look at are the User model and Wizard controller.
app/models/User.java
In your model you assign constraints to specific groups. The groups seem to just be interfaces defined within the model class.
#Required(groups = {All.class, Step1.class})
#MinLength(value = 4, groups = {All.class, Step1.class})
public String username;
app/controllers/Wizard.java
Now when you do your form binding you pass in the group/interface class that you want to validate.
Form<User> filledForm = form(User.class, User.Step1.class).bindFromRequest();

Creating custom user attributes in Active Directory using JNDI

I am attempting to create a custom attribute that can be assigned to an existing Active Directory user in my domain. I am not fully aware of how to achieve this. It is my understanding that once the attribute has been created, I can assign it to the user via:
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("attributeName", "attributeValue"))
ctx.modifyAttributes(userDN, mods)
Any information is appreciated.
Not sure what you want to do.
But Active-Directory is a Directory, so it use a SCHEMA to define which attributes can be used in an object. This means that you can modify (add, delete, replace) the value of an attribut that exists (in the SCHEMA) for a given class, but can'nt add a custom attribut to a class without modifying the SCHEMA.

Categories