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 {
@PathVariable String phaseId,
@RequestBody Card card) throws Exception {
templateCache.correctCardFieldTypes(card);
templateCache.correctCardFieldTypes(boardId, card);
ObjectContentManager ocm = ocmFactory.getOcm();
try{
......@@ -261,7 +261,7 @@ public class CardController {
// Add Fields
for( Entry<String,Object> entry : card.getFields().entrySet()){
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);
}
storeCardEvent(URI.HISTORY_URI,"Creating Card",boardId, phaseId, card.getId().toString(),
......@@ -387,7 +387,7 @@ public class CardController {
Node node =
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;
try {
......
......@@ -102,6 +102,7 @@ public class ResourceController {
String newValue = reader.readLine();
if( newValue!=null){
valueBuilder.append(newValue);
valueBuilder.append("\n");
} else {
break;
}
......
......@@ -63,10 +63,10 @@ public class TemplateCache extends CacheImpl<Template>{
@Autowired
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>();
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){
resultFields.put( fieldName, value);
}
......@@ -74,7 +74,7 @@ public class TemplateCache extends CacheImpl<Template>{
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){
return null;
......@@ -82,7 +82,7 @@ public class TemplateCache extends CacheImpl<Template>{
Template template;
try {
template = getItem( templateId);
template = getItem( boardId, templateId);
} catch( ResourceNotFoundException e){
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