Ce gestionnaire classe les documents dans des dossiers déterminés par les événements déclenchés sur les documents.
Gestionnaire de classement de documents |
---|
Content Engine 3.5.x version JScript |
function OnEvent (Event, Subscription) { var doc = Event.SourceObject; if (Event.IsOfClass("CreationEvent")) { FileDocInFolder("/Docs", doc); } else if (Event.IsOfClass("ChangeClassEvent")) { FileDocInFolder("/Archives", doc); } } function FileDocInFolder(otherFolderName, doc) { var os = doc.ObjectStore; var rootFld = os.RootFolder; var fldSet = new Enumerator(rootFld.SubFolders); var subFld; for (; !fldSet.atEnd(); fldSet.moveNext()) { subFld = fldSet.item(); if (subFld.Name == otherFolderName) { subFld.File(doc, 0, doc.DocumentTitle); } } } |
Content Engine 4.x version Java |
import com.filenet.api.constants.*; import com.filenet.api.constants.DefineSecurityParentage; import com.filenet.api.core.*; import com.filenet.api.engine.EventActionHandler; import com.filenet.api.events.ObjectChangeEvent; import com.filenet.api.exception.EngineRuntimeException; import com.filenet.api.exception.ExceptionCode; import com.filenet.api.util.Id; public class FileDocumentAction implements EventActionHandler { public void onEvent(ObjectChangeEvent event, Id subscriptionId) throws EngineRuntimeException { Document doc = (Document)event.get_SourceObject(); try { if (event.getClassName().equalsIgnoreCase("CreationEvent")) FileDocInFolder("/docs", doc); else if (event.getClassName().equalsIgnoreCase("ChangeClassEvent")) FileDocInFolder("/Archives", doc); } catch (Exception e) { throw new EngineRuntimeException(ExceptionCode.E_FAILED); } } public void fileDocInFolder(String folderName, Document doc) { try { Folder folder = (Folder)doc.getObjectStore().getObject("Folder", folderName); ReferentialContainmentRelationship rel = folder.file (doc, AutoUniqueName.AUTO_UNIQUE, doc.get_Name(), DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE); rel.save(RefreshMode.NO_REFRESH); } catch (Exception e) { e.printStackTrace(); } } } |