Modifying list and sending it to front end sends original list - jsf-2

I couldn't phrase my Title better, but what's happening is: I fetch a list when the page opens, but it should remove one member of it based on something the user does on the page.
I'm using a ui:repeat in the front-end, and the getter method of this list is:
public List<Employee> getAvailableLoaders() {
if (availableLoaderList != null) {
List<Employee> availableLoaderListWithoutDriver = new ArrayList(availableLoaderList);
if (selectedDriver != null) {
logInfo("SelectedDriver is: " + selectedDriver.getName());
logInfo("List's size before removal is: " + availableLoaderListWithoutDriver.size());
logInfo("Removal was successfull? " + availableLoaderListWithoutDriver.remove(selectedDriver));
logInfo("List's size after removal is: " + availableLoaderListWithoutDriver.size());
}
return availableLoaderListWithoutDriver;
}
return null;
}
And my logs say:
Info: SelectedDriver is: [Driver name]
Info: List's size before removal is: 5
Info: Removal was successful? true
Info: List's size after removal is: 4
But it still shows a list with the driver removed and 5 members anyway. I know the getter is being called with the correct info and when the place that shows it is called because I'm watching the logs.
Any explanation or suggestion on how should I do this or am I just doing a really stupid mistake?

Related

How to resolve 'groovy.lang.MissingMethodException' ...Possible solutions: notify(), render(java.lang.String)

I am very new to Groovy and this is an old application where the author is no longer with our organization. None of the previous questions that look similar offered any help. The application needs to send a simple message to the user to warn they are missing an entry before they con continue on.
I have made no fewer than 20 changes from flash.message to confirm. Flash causes the application to jump all the way to the user login function. This confirm is giving a crash message: Error 500: Executing action [submitrequest] of controller [SdrmController] caused exception: Runtime error executing action
def submitrequest = {
def testChecker
testChecker = [params.fullExpName].flatten().findAll { it != null }
log.info('testChecker.size = ' + testChecker.size)
if (testChecker.size > 0) {
if (!confirm('Submitting can not be undone, are you sure?')) return
} else {
if (!confirm('You have to pick an expedition. Please return to your Request and pick at least one expedition.')) return
} else {
return
}
}
// rest of long time working code here
}
Expected Result is a simple message to screen tell the user to pick an "Expedition" from a list and then the code returns to the same point so the user can make the change then hit the submit again.
Then full message:
No signature of method: SdrmController.confirm() is applicable for argument types: (java.lang.String) values: [You have to pick an expedition. Please return to your Request and pick at least one expedition.] Possible solutions: notify(), render(java.lang.String)
-- flash.message worked for our situation.
`legChecker = [params.programLeg].flatten().findAll{it!=null}
if(requestInstance.futurePast == "future" && expChecker.size<1) {
flash.message = " you must select a future expedition "
render(view: 'stepstart', model: [....])
return
}`

Return message in Jira out of Java (is only visible after page refresh...)

I have problems with returning a message in Jira out of Java.
I made a plugin, overwriting the CreateWorklog class (the doExecute() method) when creating an issue.
After my functionalities the method ends with those lines:
[...]
if (NONE.equals(superResult))
{
return returnMsgToUser(getReturnUrl(), messageToUser, MessageType.SUCCESS, true, null);
}
return superResult;
And before that, there are some options to return before creating the issue, those look like this for example:
[...]
if (httpPostReq.getResponseCode() != 201)
{
System.out.println("ERROR: Webservice-Aufruf fehlgeschlagen! Response-Code: " + httpPostReq.getResponseCode());
return returnMsgToUser(getReturnUrl(), "ERROR: Webservice call failed! Response-Code: " + httpPostReq.getResponseCode(), MessageType.ERROR, true, null);
}
[...]
The return argument makes the method cancels the issue-creation, but the return message is not as wanted.
First, the normal return message of the unchanged function appears, but after reloading the website, my own message appears.
Why it's only visible after refreshing the Jira website? How could I change that behavior?
And another question:
What exactly is the String target (last constructor parameter) doing in returnMsgToUser? The only information I could find, is that if you put in null, it's placed in a global spot. And what else could you put in there? I have no ideas...

accessing transition history via JIRA REST API

I found another person apparently having this issue but I thought I'd re-ask the question to see if I could make it more explicit.
I'm using the JIRA 6 REST web API and successfully pulling lots of data that matches our web cloud UI.
Now I'd like to see the transitions a given issue has been thru, preferably with info about who performed the transition.
I can see this transition history in our JIRA web UI but I haven't figured out how to access programmatically yet.
There's a promising sounding API:
http://example.com:8080/jira/rest/api/2/issue/{issueIdOrKey}/transitions [GET, POST]
And this is the API the previous asker seemed to have been using. From what I can tell it only returns the valid transitions you can ask for on the issue at a given point in time.
I would like a history of transitions, such as when the issue went to code review, QA, closed, etc.
I have done a expand=changelog but the change log does not correlate with the transitions that I can see.
Any tips would be appreciated. Thanks.
When you use expand=changelog, then all changes that have been done in issue are there. Exactly same info as in All tab in Activity section when viewing in web browser.
When I send:
http://jira.my.server.se/rest/api/2/issue/KEYF-42346?expand=changelog
Under changelogkey I find list of histories. Each historyhas list of items. Those items are changes performed on the certain field, with to and from values.
To find all status changes you need to do something like this:
for history in issue.changelog.histories:
for item in history.items:
if item.field == "status":
print item.toString # new value
print item.fromString # old value
Or use GET /rest/api/3/issue/{issueIdOrKey}/changelog like explained in the "get changelog" docs
You can try using the jql parameter for the REST API call.
So your call for,
JQL = project=XYZ and status was resolved
fields = key
will look like this,
http://example.com/rest/api/2/search?jql=project%3DXYZ%20and%20status%20was%20resolved&fields=key
where key will return only relevant information and not excessive for each issue.
public void changeStatus(IssueRestClient iRestClient,
List<Statuses> JiraStatuses, String key) {
String status = "To Do";
for (Statuses statuses : vOneToJiraStatuses) {
if (1 == statuses.compareTo(status)) {
try {
String _transition = statuses.getTransition();
Issue issue = iRestClient.getIssue(key).get();
Transition transition = getTransition(iRestClient, issue,
_transition);
if (!(isBlankOrNull(transition))) {
if (!(issue.getStatus().getName()
.equalsIgnoreCase(_transition)))
transition(transition, issue, null, iRestClient,
status);
}
} catch (Exception e) {
Constants.ERROR.info(Level.INFO, e);
}
break;
}
}
}
List is a pojo implementation where statuses and transitions defined in xml are injected through setter/constructor.
private void transition(Transition transition, Issue issue,
FieldInput fieldInput, IssueRestClient issueRestClient,
String status) throws Exception {
if (isBlankOrNull(fieldInput)) {
TransitionInput transitionInput = new TransitionInput(
transition.getId());
issueRestClient.transition(issue, transitionInput).claim();
Constants.REPORT.info("Status Updated for : " + issue.getKey());
} else {
TransitionInput transitionInput = new TransitionInput(
transition.getId());
issueRestClient.transition(issue, transitionInput).claim();
Constants.REPORT.info("Status Updated for : " + issue.getKey());
}
}
public Transition getTransition(IssueRestClient issueRestClient,
Issue issue, String _transition) {
Promise<Iterable<Transition>> ptransitions = issueRestClient
.getTransitions(issue);
Iterable<Transition> transitions = ptransitions.claim();
for (Transition transition : transitions) {
if (transition.getName().equalsIgnoreCase(_transition)) {
return transition;
}
}
return null;
}
In Short using Transition API of JIRA we can fetch all the transitions to set statuses

Arabic input fields in unity

Is there is a way to change the language of input fields in unity to Arabic?. I tried ArabicSupport and it displayed Arabic correctly but using it with input fields didn't work because
GameObject.Find("input_field")
.GetComponent<InputField>().text = Fix3dTextCS.fix(
GameObject.Find("input_field").GetComponent<InputField>().text
);
caused an error so, if I printed the input text elsewhere, it will appear correctly but how can I do it with the same input field?
input field is a little bit tricky to let it work with Arabic Support
please try this opensource asset it has an prefab for Arabic Input Field and some other UIs.
OpenSource for ArabicSupport Solution Link
OpenSource for unity asset UI Arabic Support: Link
Have you tried adding arabic font in that input.
If so, post the error message it may help to find the bug
Using Font won't help because it will only change the theme of your current Input usage but not how you use to input in the Device.
You will need to use Input.Location <- Input is static so you can access it anywhere. The only problem is, I am not sure what is the exact variable for arabic is. My best guess is Input.Location = "Arabic" or "arabic".
If you want to automatically detect their location, the GPS which will unity3d turn on by calling Input.Location.Start, and turn off by Input.Location.Stop()
Here is a sample code for you.
using UnityEngine;
using System.Collections;
public class TestLocationService : MonoBehaviour
{
IEnumerator Start()
{
// First, check if user has location service enabled
if (!Input.location.isEnabledByUser) yield break;
// Start service before querying location
Input.location.Start();
// Wait until service initializes
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
yield return new WaitForSeconds(1);
maxWait--;
}
// Service didn't initialize in 20 seconds
if (maxWait < 1)
{
print("Timed out");
yield break;
}
// Connection has failed
if (Input.location.status == LocationServiceStatus.Failed)
{
print("Unable to determine device location");
yield break;
}
else
{
// Access granted and location value could be retrieved
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
}
// Stop service if there is no need to query location updates continuously
Input.location.Stop();
}
}

neo4j 2.0 findNodesByLabelAndProperty not working

I'm currently trying the Neo4j 2.0.0 M3 and see some strange behaviour. In my unit tests, everything works as expected (using an newImpermanentDatabase) but in the real thing, I do not get results from the graphDatabaseService.findNodesByLabelAndProperty.
Here is the code in question:
ResourceIterator<Node> iterator = graphDB
.findNodesByLabelAndProperty(Labels.User, "EMAIL_ADDRESS", emailAddress)
.iterator();
try {
if (iterator.hasNext()) { // => returns false**
return iterator.next();
}
} finally {
iterator.close();
}
return null;
This returns no results. However, when running the following code, I see my node is there (The MATCH!!!!!!!!! is printed) and I also have an index setup via the schema (although that if I read the API, this seems not necessary but is important for performance):
ResourceIterator<Node> iterator1 = GlobalGraphOperations.at(graphDB).getAllNodesWithLabel(Labels.User).iterator();
while (iterator1.hasNext()) {
Node result = iterator1.next();
UserDao.printoutNode(emailAddress, result);
}
And UserDao.printoutNode
public static void printoutNode(String emailAddress, Node next) {
System.out.print(next);
ResourceIterator<Label> iterator1 = next.getLabels().iterator();
System.out.print("(");
while (iterator1.hasNext()) {
System.out.print(iterator1.next().name());
}
System.out.print("): ");
for(String key : next.getPropertyKeys()) {
System.out.print(key + ": " + next.getProperty(key).toString() + "; ");
if(emailAddress.equals( next.getProperty(key).toString())) {
System.out.print("MATCH!!!!!!!!!");
}
}
System.out.println();
}
I already debugged through the code and what I already found out is that I pass via the InternalAbstractGraphDatabase.map2Nodes to a DelegatingIndexProxy.getDelegate and end up in IndexReader.Empty class which returns the IteratorUtil.EMPTY_ITERATOR thus getting false for iterator.hasNext()
Any idea's what I am doing wrong?
Found it:
I only included neo4j-kernel:2.0.0-M03 in the classpath. The moment I added neo4j-cypher:2.0.0-M03 all was working well.
Hope this answer helps save some time for other users.
#Neo4j: would be nice if an exception would be thrown instead of just returning nothing.
#Ricardo: I wanted to but I was not allowed yet as my reputation wasn't good enough as a new SO user.

Resources