Commit 7a3c0fba authored by Peter Harrison's avatar Peter Harrison

Fix issue with Templates not loading in automation.

Add carriage returns when saving resources.
parent f6f54c51
...@@ -238,7 +238,7 @@ public class CardController { ...@@ -238,7 +238,7 @@ public class CardController {
@PathVariable String phaseId, @PathVariable String phaseId,
@RequestBody Card card) throws Exception { @RequestBody Card card) throws Exception {
templateCache.correctCardFieldTypes(card); templateCache.correctCardFieldTypes(boardId, card);
ObjectContentManager ocm = ocmFactory.getOcm(); ObjectContentManager ocm = ocmFactory.getOcm();
try{ try{
...@@ -261,7 +261,7 @@ public class CardController { ...@@ -261,7 +261,7 @@ public class CardController {
// Add Fields // Add Fields
for( Entry<String,Object> entry : card.getFields().entrySet()){ for( Entry<String,Object> entry : card.getFields().entrySet()){
Object correctedValue = Object correctedValue =
templateCache.correctFieldType( entry.getKey(), entry.getValue(), card.getTemplate()); templateCache.correctFieldType( entry.getKey(), entry.getValue(), card.getBoard(), card.getTemplate());
updateValue( node, entry.getKey(), correctedValue, null); updateValue( node, entry.getKey(), correctedValue, null);
} }
storeCardEvent(URI.HISTORY_URI,"Creating Card",boardId, phaseId, card.getId().toString(), storeCardEvent(URI.HISTORY_URI,"Creating Card",boardId, phaseId, card.getId().toString(),
...@@ -387,7 +387,7 @@ public class CardController { ...@@ -387,7 +387,7 @@ public class CardController {
Node node = Node node =
ocm.getSession().getNode(String.format(URI.FIELDS_URI, card.getBoard(), card.getPhase(), card.getId())); ocm.getSession().getNode(String.format(URI.FIELDS_URI, card.getBoard(), card.getPhase(), card.getId()));
Object correctedValue = templateCache.correctFieldType(field, value, card.getTemplate()); Object correctedValue = templateCache.correctFieldType(field, value, card.getBoard(), card.getTemplate());
Object currentValue = null; Object currentValue = null;
try { try {
......
...@@ -102,6 +102,7 @@ public class ResourceController { ...@@ -102,6 +102,7 @@ public class ResourceController {
String newValue = reader.readLine(); String newValue = reader.readLine();
if( newValue!=null){ if( newValue!=null){
valueBuilder.append(newValue); valueBuilder.append(newValue);
valueBuilder.append("\n");
} else { } else {
break; break;
} }
......
...@@ -63,10 +63,10 @@ public class TemplateCache extends CacheImpl<Template>{ ...@@ -63,10 +63,10 @@ public class TemplateCache extends CacheImpl<Template>{
@Autowired @Autowired
ListTools listTools; ListTools listTools;
public void correctCardFieldTypes(Card card) throws Exception{ public void correctCardFieldTypes(String boardId, Card card) throws Exception{
Map<String, Object> resultFields = new HashMap<String, Object>(); Map<String, Object> resultFields = new HashMap<String, Object>();
for( String fieldName : card.getFields().keySet() ){ for( String fieldName : card.getFields().keySet() ){
Object value = correctFieldType( fieldName, card.getFields().get(fieldName), card.getTemplate()); Object value = correctFieldType( fieldName, card.getFields().get(fieldName), boardId, card.getTemplate());
if( value!=null){ if( value!=null){
resultFields.put( fieldName, value); resultFields.put( fieldName, value);
} }
...@@ -74,7 +74,7 @@ public class TemplateCache extends CacheImpl<Template>{ ...@@ -74,7 +74,7 @@ public class TemplateCache extends CacheImpl<Template>{
card.setFields(resultFields); card.setFields(resultFields);
} }
public Object correctFieldType(String fieldName, Object value, String templateId) throws Exception { public Object correctFieldType(String fieldName, Object value, String boardId, String templateId) throws Exception {
if( value==null){ if( value==null){
return null; return null;
...@@ -82,7 +82,7 @@ public class TemplateCache extends CacheImpl<Template>{ ...@@ -82,7 +82,7 @@ public class TemplateCache extends CacheImpl<Template>{
Template template; Template template;
try { try {
template = getItem( templateId); template = getItem( boardId, templateId);
} catch( ResourceNotFoundException e){ } catch( ResourceNotFoundException e){
return value; return value;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment