001: package org.drools.brms.client.rpc;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
020:
021: import com.google.gwt.user.client.rpc.RemoteService;
022: import com.google.gwt.user.client.rpc.SerializableException;
023:
024: /**
025: * This is what the remote service will implement, as a servlet.
026: * (in hosted/debug mode, you could also use an implementation that was in-process).
027: */
028: public interface RepositoryService extends RemoteService {
029:
030: /**
031: * @param categoryPath A "/" delimited path to a category.
032: * @param callback
033: */
034: public String[] loadChildCategories(String categoryPath);
035:
036: /**
037: * Return a a 2d array/grid of results for rules.
038: * @param A "/" delimited path to a category.
039: */
040: public TableDataResult loadRuleListForCategories(String categoryPath)
041: throws SerializableException;
042:
043: /**
044: * This will return a TableConfig of header names.
045: * @param listName The name of the list that we are going to render.
046: */
047: public TableConfig loadTableConfig(String listName);
048:
049: /**
050: * This will create a new category at the specified path.
051: */
052: public Boolean createCategory(String path, String name,
053: String description);
054:
055: /**
056: * Creates a brand new rule with the initial category.
057: * Return the UUID of the item created.
058: * This will not check in the rule, but just leave it as saved in the repo.
059: */
060: public String createNewRule(String ruleName, String description,
061: String initialCategory, String initialPackage, String format)
062: throws SerializableException;
063:
064: /**
065: * Delete un checked in Asset
066: */
067: public void deleteUncheckedRule(String ruleName,
068: String initialPackage);
069:
070: /**
071: * Export rules repository to a compressed array of bytes
072: */
073: public byte[] exportRepository() throws SerializableException;
074:
075: /**
076: * Clear the rules repositoty, Use at your own risk.
077: */
078: public void clearRulesRepository();
079:
080: /**
081: * This returns a list of packages where rules may be added.
082: * Only the UUID and the name need to be populated.
083: */
084: public PackageConfigData[] listPackages();
085:
086: /**
087: * This loads up all the stuff for a
088: * rule asset based on the UUID (always latest and editable version).
089: */
090: public RuleAsset loadRuleAsset(String UUID)
091: throws SerializableException;
092:
093: /**
094: * This will load the history of the given asset, in a summary format suitable
095: * for display in a table.
096: */
097: public TableDataResult loadAssetHistory(String uuid)
098: throws SerializableException;
099:
100: /**
101: * This will load all archived assets, in a summary format suitable
102: * for display in a table.
103: */
104:
105: public TableDataResult loadArchivedAssets()
106: throws SerializableException;
107:
108: /**
109: * This checks in a new version of an asset.
110: * @return the UUID of the asset you are checking in,
111: * null if there was some problem (and an exception was not thrown).
112: */
113: public String checkinVersion(RuleAsset asset)
114: throws SerializableException;
115:
116: /**
117: * This will restore the specified version in the repository, saving, and creating
118: * a new version (with all the restored content).
119: */
120: public void restoreVersion(String versionUUID, String assetUUID,
121: String comment);
122:
123: /**
124: * This creates a package of the given name, and checks it in.
125: * @return UUID of the created item.
126: */
127: public String createPackage(String name, String description)
128: throws SerializableException;
129:
130: /**
131: * Loads a package by its uuid.
132: * @return Well, its pretty obvious if you think about it for a minute. Really.
133: */
134: public PackageConfigData loadPackageConfig(String uuid);
135:
136: /**
137: * Saves the package config data in place (does not create a new version of anything).
138: * @return A ValidatedReponse, with any errors to be reported.
139: * No payload is in the response. If there are any errors, the user
140: * should be given the option to review them, and correct them if needed
141: * (but a save will not be prevented this way - as its not an exception).
142: */
143: public ValidatedResponse savePackage(PackageConfigData data)
144: throws SerializableException;
145:
146: /**
147: * Given a format, this will return assets that match.
148: * It can also be used for "pagination" by passing in start and
149: * finish row numbers.
150: * @param packageUUID The package uuid to search inside.
151: * @param format The format to filter on.
152: * @param numRows The number of rows to return. -1 means all.
153: * @param startRow The starting row number if paging - if numRows is -1 then this is ignored.
154: */
155: public TableDataResult listAssets(String packageUUID,
156: String formats[], int numRows, int startRow)
157: throws SerializableException;
158:
159: /**
160: * Returns a list of valid states.
161: */
162: public String[] listStates() throws SerializableException;
163:
164: /**
165: * Create a state (status).
166: * @return the UUID of the created StateItem.
167: */
168: public String createState(String name) throws SerializableException;
169:
170: /**
171: * This will change the state of an asset or package.
172: * @param uuid The UUID of the asset we are tweaking.
173: * @param newState The new state to set. It must be valid in the repo.
174: * @param wholePackage true if it is a package we are setting the state of.
175: * If this is true, UUID must be the status of a package, if false, it must be an asset.
176: */
177: public void changeState(String uuid, String newState,
178: boolean wholePackage);
179:
180: /**
181: * This moves an asset to the given target package.
182: */
183: public void changeAssetPackage(String uuid, String newPackage,
184: String comment);
185:
186: /**
187: * Copies an asset into a new destination package.
188: * @param assetUUID The source assetID.
189: * @param newPackage The destination package (may be the same as the current source package, but
190: * in that case the asset has to have a different name).
191: * @param newName The new name of the asset.
192: */
193: public String copyAsset(String assetUUID, String newPackage,
194: String newName);
195:
196: /**
197: * Copy the package (everything).
198: * @param sourcePackageName
199: * @param destPackageName
200: */
201: public void copyPackage(String sourcePackageName,
202: String destPackageName) throws SerializableException;
203:
204: /**
205: * This will load a list of snapshots for the given package. Snapshots are created
206: * by taking a labelled copy of a package, at a point in time, for instance for deployment.
207: */
208: public SnapshotInfo[] listSnapshots(String packageName);
209:
210: /**
211: * Create a package snapshot for deployment.
212: * @param packageName THe name of the package to copy.
213: * @param snapshotName The name of the snapshot. Has to be unique unless existing one is to be replaced.
214: * @param replaceExisting Replace the existing one (must be true to replace an existing snapshot of the same name).
215: * @param comment A comment to be added to the copied one.
216: */
217: public void createPackageSnapshot(String packageName,
218: String snapshotName, boolean replaceExisting, String comment);
219:
220: /**
221: * This alters an existing snapshot, it can be used to copy or delete it.
222: * @param packageName The package name that we are dealing with.
223: * @param snapshotName The snapshot name (this must exist)
224: * @param delete true if the snapshotName is to be removed.
225: * @param newSnapshotName The name of the target snapshot that the contents will be copied to.
226: */
227: public void copyOrRemoveSnapshot(String packageName,
228: String snapshotName, boolean delete, String newSnapshotName)
229: throws SerializableException;
230:
231: /**
232: * This will quickly return a list of asset names/descriptions.
233: * This list will be limited, and it will be flagged if more are found then can be shown.
234: * Returning an extra empty row means there are more to come...
235: *
236: * The id of a row is the UUID, the first value is the name, the next the description.
237: * Finally, if there is "more" rows, a row will be returned which has "MORE" as its ID.
238: *
239: */
240: public TableDataResult quickFindAsset(String searchText,
241: int maxMatches, boolean searchArchived);
242:
243: /**
244: * This will remove a category. A category must have no
245: * current assets linked to it, or else it will not be able to be removed.
246: * @param categoryPath The full path to the category. Any sub categories will also
247: * be removed.
248: * @throws SerializableException For when it all goes horribly wrong.
249: */
250: public void removeCategory(String categoryPath)
251: throws SerializableException;
252:
253: /**
254: * Loads up the SuggestionCompletionEngine for the given package.
255: * As this doesn't change that often, its safe to cache. However, if a change is made to
256: * a package, should blow away the cache.
257: */
258: public SuggestionCompletionEngine loadSuggestionCompletionEngine(
259: String packageName) throws SerializableException;
260:
261: /**
262: * Build the package (may be a snapshot) and return the result.
263: *
264: * This will then store the result in the package as an attachment.
265: *
266: * if a non null selectorName is passed in it will lookup a selector as configured
267: * in the systems selectors.properties file. This will then apply the filter to the
268: * package being built.
269: */
270: public BuilderResult[] buildPackage(String packageUUID,
271: String selectorName) throws SerializableException;
272:
273: /**
274: * This will return the effective DRL for a package.
275: * This would be the equivalent if all the rules were written by hand in the one file.
276: * It may not actually be compiled this way in the implementation, so this is for display and
277: * debugging assistance only.
278: *
279: * It should still generate
280: *
281: * @throws SerializableException
282: */
283: public String buildPackageSource(String packageUUID)
284: throws SerializableException;
285:
286: /**
287: * This will return the effective source for an asset (in DRL).
288: * Used as an aid for debugging.
289: */
290: public String buildAssetSource(RuleAsset asset)
291: throws SerializableException;
292:
293: /**
294: * This will build the asset and return any build results (errors).
295: * This is only to report on the results - it will generally not store any state or apply any changed.
296: */
297: public BuilderResult[] buildAsset(RuleAsset asset)
298: throws SerializableException;
299:
300: /**
301: * Rename an asset.
302: */
303: public String renameAsset(String uuid, String newName);
304:
305: /**
306: * Archive asset based on uuid
307: * @param uuid
308: */
309: public void archiveAsset(String uuid, boolean value);
310:
311: /**
312: * Remove an asset based on uuid
313: * @param uuid
314: */
315: public void removeAsset(String uuid);
316:
317: /**
318: * Rename a package.
319: */
320: public String renamePackage(String uuid, String newName);
321:
322: }
|