Skip to content

Commit

Permalink
add contributor comment in text mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DunaMariusCosmin committed Oct 31, 2017
1 parent 7751cbd commit 099b765
Showing 1 changed file with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private void updateCritdates(boolean isNewDocument) {
String toAdd = "<critdates>\n" + prologContentCreater.getDateXmlFragment(isNewDocument) + "\n</critdates>";
addXmlFragment(toAdd, "//*[contains(@class,'topic/prolog')]/author[last()]",
RelativeInsertPosition.INSERT_LOCATION_AFTER);

} else {
// the critdates element exists
if (isNewDocument) {
Expand Down Expand Up @@ -141,10 +142,11 @@ private void updateCritdates(boolean isNewDocument) {
}
} else {
//it's not a new document
//search for revised elements that have local date as modified value.
WSXMLTextNodeRange[] revisedElements = wsTextEditorPage
//search for revised elements that have local date as modified and have contributor as comment
Object[] revisedElements = wsTextEditorPage
.findElementsByXPath("//*[contains(@class,'topic/prolog')]/critdates/revised[@modified = '"
+ prologContentCreater.getLocalDate() + "']");
+ prologContentCreater.getLocalDate() + "']/"
+ "preceding-sibling::node()[2][.='"+prologContentCreater.getAuthor()+"']");

//if the element wasn't found
if (revisedElements.length == 0) {
Expand Down Expand Up @@ -194,27 +196,11 @@ private void updateAuthor( boolean isNewDocument) {
// add the creator author xml fragment
addXmlFragment(prologContentCreater.getAuthorCreatorXmlFragment(), "//*[contains(@class,'topic/prolog')]",
RelativeInsertPosition.INSERT_LOCATION_AS_FIRST_CHILD);
} else {
// was found a creator
if (creatorAuthorElements[0] instanceof ElementNSImpl) {
ElementNSImpl currentCreatorAuthor = (ElementNSImpl) creatorAuthorElements[0];
// check if the text content is empty
System.out.println("textConte:"+ currentCreatorAuthor.getTextContent());
if (currentCreatorAuthor.getTextContent().isEmpty()) {
System.out.println("isEmpty");
//TODO Problema aici(setTextContent)
//set the author text content
try {
currentCreatorAuthor.setTextContent(prologContentCreater.getAuthor());
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}

} else {
// the document isn't new
// search for a contributor author that has local author name as text.
// search for a contributor author that has local author name as text
Object[] contributorAuthorElements = wsTextEditorPage.evaluateXPath("//*[contains(@class,'topic/prolog')]/"
+ "author[@type='contributor' and text()= '" + prologContentCreater.getAuthor() + "']");
int contributorElementSize = contributorAuthorElements.length;
Expand Down

0 comments on commit 099b765

Please sign in to comment.