From 1e67b454efd84a88877205917038da13a47a2f6b Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 9 Nov 2012 09:51:18 +0100 Subject: Create proper constructor for Schema. --- .../java/com/c2kernel/utils/LocalObjectLoader.java | 36 ++++++++++------------ 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/main/java/com/c2kernel/utils') diff --git a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java index 8a73e3c..6832eeb 100644 --- a/src/main/java/com/c2kernel/utils/LocalObjectLoader.java +++ b/src/main/java/com/c2kernel/utils/LocalObjectLoader.java @@ -37,29 +37,25 @@ public class LocalObjectLoader { static public Schema getSchema(String schemaName, int schemaVersion) throws ObjectNotFoundException { Logger.msg(5, "Loading schema "+schemaName+" v"+schemaVersion); - Schema thisSchema = new Schema(); - thisSchema.docType = schemaName; - thisSchema.docVersion = schemaVersion; + + String docType = schemaName; + int docVersion = schemaVersion; + String schemaData; // don't bother if this is the Schema schema - for bootstrap esp. - if (schemaName.equals("Schema") && schemaVersion == 0) { - thisSchema.breakApart = false; - thisSchema.schema=""; - return thisSchema; - } - - ItemProxy schema = loadLocalObjectDef("/desc/OutcomeDesc/", schemaName); - Viewpoint schemaView = (Viewpoint)schema.getObject(ClusterStorage.VIEWPOINT + "/Schema/" + schemaVersion); - try { - thisSchema.schema = schemaView.getOutcome().getData(); - } catch (ClusterStorageException ex) { - Logger.error(ex); - throw new ObjectNotFoundException("Problem loading schema "+schemaName+" v"+schemaVersion+": "+ex.getMessage(), ""); - } - String breakApart = schema.getProperty("BreakApart"); - thisSchema.breakApart = breakApart.equals("1"); + if (schemaName.equals("Schema") && schemaVersion == 0) + return new Schema(docType, docVersion, false, ""); - return thisSchema; + ItemProxy schema = loadLocalObjectDef("/desc/OutcomeDesc/", schemaName); + Viewpoint schemaView = (Viewpoint)schema.getObject(ClusterStorage.VIEWPOINT + "/Schema/" + schemaVersion); + try { + schemaData = schemaView.getOutcome().getData(); + } catch (ClusterStorageException ex) { + Logger.error(ex); + throw new ObjectNotFoundException("Problem loading schema "+schemaName+" v"+schemaVersion+": "+ex.getMessage(), ""); + } + String breakApart = schema.getProperty("BreakApart"); + return new Schema(docType, docVersion, breakApart.equals("1"), schemaData); } /** -- cgit v1.2.3