01: package org.drools.brms.server.contenthandler;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.io.IOException;
20: import java.io.StringReader;
21:
22: import org.drools.brms.client.rpc.RuleAsset;
23: import org.drools.brms.server.builder.BRMSPackageBuilder;
24: import org.drools.brms.server.builder.ContentPackageAssembler.ErrorLogger;
25: import org.drools.compiler.DroolsParserException;
26: import org.drools.decisiontable.InputType;
27: import org.drools.decisiontable.SpreadsheetCompiler;
28: import org.drools.repository.AssetItem;
29: import org.drools.repository.PackageItem;
30:
31: import com.google.gwt.user.client.rpc.SerializableException;
32:
33: /**
34: * This is for handling XLS content (classic decision tables).
35: *
36: * @author Michael Neale
37: */
38: public class DecisionTableXLSHandler extends ContentHandler implements
39: IRuleAsset {
40:
41: public void retrieveAssetContent(RuleAsset asset, PackageItem pkg,
42: AssetItem item) throws SerializableException {
43: //do nothing, as we have an attachment
44: }
45:
46: public void storeAssetContent(RuleAsset asset, AssetItem repoAsset)
47: throws SerializableException {
48: //do nothing, as we have an attachment
49: }
50:
51: public void assembleDRL(BRMSPackageBuilder builder,
52: AssetItem asset, StringBuffer buf) {
53: SpreadsheetCompiler comp = new SpreadsheetCompiler();
54: String drl = comp.compile(asset.getBinaryContentAttachment(),
55: InputType.XLS);
56: buf.append(drl);
57: }
58:
59: public void compile(BRMSPackageBuilder builder, AssetItem asset,
60: ErrorLogger logger) throws DroolsParserException,
61: IOException {
62: SpreadsheetCompiler comp = new SpreadsheetCompiler();
63: String drl = comp.compile(builder.getPackage(), asset
64: .getBinaryContentAttachment(), InputType.XLS);
65: builder.addPackageFromDrl(new StringReader(drl));
66:
67: }
68:
69: }
|