Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.workbench.models.guided.dtable.backend;
 
 
 
 @SuppressWarnings("deprecation")
 public class GuidedDTXMLPersistence {
 
     private XStream xt;
     private static final GuidedDTXMLPersistence INSTANCE = new GuidedDTXMLPersistence();
 
     private GuidedDTXMLPersistence() {
          = new XStreamnew DomDriver() );
 
         //Legacy model
         .alias"decision-table",
                   GuidedDecisionTable.class );
         .alias"metadata-column",
                   MetadataCol.class );
         .alias"attribute-column",
                   AttributeCol.class );
         .alias"condition-column",
                   ConditionCol.class );
         .alias"set-field-col",
                   ActionSetFieldCol.class );
         .alias"retract-fact-column",
                   ActionRetractFactCol.class );
         .alias"insert-fact-column",
                   ActionInsertFactCol.class );
 
         //Post 5.2 model
         .alias"decision-table52",
                   GuidedDecisionTable52.class );
         .alias"metadata-column52",
                   MetadataCol52.class );
         .alias"attribute-column52",
                   AttributeCol52.class );
         .alias"condition-column52",
                   ConditionCol52.class );
         .alias"set-field-col52",
                   ActionSetFieldCol52.class );
         .alias"retract-fact-column52",
                   ActionRetractFactCol52.class );
         .alias"insert-fact-column52",
                   ActionInsertFactCol52.class );
         .alias"value",
                   DTCellValue52.class );
         .alias"Pattern52",
         		Pattern52.class );
         
         //See https://issues.jboss.org/browse/GUVNOR-1115
         .aliasPackage"org.drools.guvnor.client",
                          "org.drools.ide.common.client");
                          
         //this is for migrating org.drools.ide.common.client.modeldriven.auditlog.AuditLog to org.drools.workbench.models.commons.shared.auditlog.AuditLog
 		.aliasPackage("org.drools.guvnor.client.modeldriven.dt52.auditlog",
 				"org.drools.workbench.models.guided.dtable.shared.auditlog");
 
 	    //this is for migrating org.drools.ide.common.client.modeldriven.dt52.auditlog.DecisionTableAuditLogFilter
		//to org.drools.workbench.models.guided.dtable.shared.auditlog.DecisionTableAuditLogFilter
		.aliasPackage("org.drools.guvnor.client.modeldriven.dt52",
				" org.drools.workbench.models.guided.dtable.shared.model");
        
        //All numerical values are historically BigDecimal
        .alias"valueNumeric",
                  Number.class,
                  BigDecimal.class );
    }
    public static GuidedDTXMLPersistence getInstance() {
        return ;
    }
    public String marshalGuidedDecisionTable52 dt ) {
        return .toXMLdt );
    }
    public GuidedDecisionTable52 unmarshalString xml ) {
        if ( xml == null || xml.trim().equals"" ) ) {
            return new GuidedDecisionTable52();
        }
        //Upgrade DTModel to new class
        Object model = .fromXMLxml );
        GuidedDecisionTable52 newDTModel;
        if ( model instanceof GuidedDecisionTable ) {
            GuidedDecisionTable legacyDTModel = (GuidedDecisionTablemodel;
            newDTModel = .upgradelegacyDTModel );
        } else {
            newDTModel = (GuidedDecisionTable52model;
        }
        //Upgrade RowNumber, Salience and Duration data-types are correct
        newDTModel = .upgradenewDTModel );
        //Upgrade Default Values to typed equivalents
        newDTModel = .upgradenewDTModel );
        return newDTModel;
    }
New to GrepCode? Check out our FAQ X