Java Agent - Form name trouble

Hi,

I’m hoping that someone can help me. This issue just became apparent, and we’re about to roll this out. It’s very strange.

I have a java agent that is run out of a database called Audits.

Audits has a Java Agent called doIt.

doIt has several classes, one of which is called Importer.

One of Importer’s functions is private void getOneItem(String field1)

getOneItem(field1) does the following

try{

	while(current <= count-1){

		doc.getFirstItem("Form");

		String formName = doc.getItemValue("Form").toString();

		System.out.println("The formName is " + formName + "from the questions database");

			//this is a question document

				if(formName.equals("[question]")){

			

			

			

						System.out.println("Doing question stuff");				

						if((doc.getFirstItem(field1) == null)) {

								doc = docs.getNextDocument();

								//current++;

						}else{

								item = doc.getFirstItem(field1);

								auditTypes[current] = item.getValues().toString();

								System.out.println(item.getValues().toString());

								System.out.println(auditTypes[current]);

								System.out.println("auditTypes.length == " + auditTypes.length);



								doc = docs.getNextDocument();

								//current++;

						} //end if else

			

			

			

			}

				//this is an employee document

				else if(formName.equals("[Employee]")){

				System.out.println("THE FORM WAS EMPLOYEE.  SHOULD NOT HAVE BEEN ADDED.");

								

				

				//current++;

		

				

		} else{

			System.out.println("its not registering as question or Employee!!!!");

			//current ++;

			}

			current++;

System.out.println("Now on " + (current - 1) + " of " + count);

	} // end while(current <= count - 1)







		

		

		auditTypes = processor.removeDuplicates(auditTypes);

		Arrays.sort(auditTypes);



	

			}catch (NullPointerException e){

				System.out.println("NULL POINTER EXCEPTION");

				e.printStackTrace();

			}catch(Exception e){

				e.printStackTrace();

				}

				//employeeArray = getManyItems();

	} //end get one item

I’m sorry about all the commented stuff and debug notes.

I’ve traced the problem to this point in the code.

I’ve got 241 documents right now, It basically looks like it recognizes all the question form documents, and as soon as it sees an employee form document, it sees all remaining documents as that type. As a result, the only choices that show are the ones that were created before the first employee form document.

To give you an idea, all those System.out.printlns give:

241

241

The formName is [question]from the questions database

Doing question stuff

[Laminator Audit]

[Laminator Audit]

auditTypes.length == 241

Now on 0 of 241

The formName is [question]from the questions database

Doing question stuff

[Laminator Audit]

[Laminator Audit]

auditTypes.length == 241

Now on 1 of 241

and so on, until:

The formName is [Employee]from the questions database

THE FORM WAS EMPLOYEE. SHOULD NOT HAVE BEEN ADDED.

Now on 75 of 241

which continues all the way until:

The formName is [Employee]from the questions database

THE FORM WAS EMPLOYEE. SHOULD NOT HAVE BEEN ADDED.

Now on 240 of 241

I’ve checked the design properties for these documents, and next to Form, it says “question” for all questions and it says “Employee” next to all employees.

Does anyone have any idea what is going on here? I’m so confused, and pretty panicked.

Let me know if you need any additional information to help with this. Thanks in advance for you help!!!

Subject: Java Agent - Form name trouble

Hi Christina,

The line

doc = docs.getNextDocument();

is performed only when form is [question].

So once the doc is [Employee] you stay with that document until the end of the loop.

Move the line out of the if-condition so it will get the next document always, and your code will work fine.

Regards,

René

Subject: RE: Java Agent - Form name trouble

Thank you thank you thank you!!! I really appreciate the fresh eyes on this. I don’t know why I couldn’t see that, but you really saved me on this.

Thanks!