ECM Filenet API - Create Class Definition
I. Giới thiệu
ECM Filenet là một hệ thống content management hữu dụng cho các doanh nghiệp.
Class Definition trong ECM Filenet giống như 1 table trong DB có các Property (Column) để định nghĩa và lưu trữ dữ liệu
Bài dưới đây sẽ hướng dẫn cách tạo mới một Class Definition thông qua api.
II. Chuẩn bị
Chuẩn bị các thư viện theo bài hướng dẫn: ecm filenet dependency
III. Sử dụng
import com.filenet.api.admin.ClassDefinition;
import com.filenet.api.admin.LocalizedString;
import com.filenet.api.admin.PropertyDefinition;
import com.filenet.api.admin.PropertyTemplate;
import com.filenet.api.collection.LocalizedStringList;
import com.filenet.api.collection.PropertyDefinitionList;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.constants.TypeID;
import com.filenet.api.core.Factory;
import com.filenet.api.core.Factory.PropertyTemplateString;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.Id;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
public Connection getConnection() {
String uri = "http://ip:port/wsi/FNCEWS40MTOM";
Connection conn = Factory.Connection.getConnection(uri);
return conn;
}
public ObjectStore getObjectStore(Connection conn) {
// Get the default domain
Domain domain = Factory.Domain.getInstance(conn, null);
// Get an object store
ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "ObjectStoreName", null);
return os;
}
public void createClassDefinition(){
ClassDefinition parentDocument = Factory.DocumentClassDefinition.fetchInstance(getObjectStore(getConnection()), "Document", null);
ClassDefinition subClass = parentDocument.createSubclass();
subClass.set_SymbolicName("DocumentTest");
LocalizedStringList localizedList = Factory.LocalizedString.createList();
LocalizedString localized = Factory.LocalizedString.createInstance();
localized.set_LocaleName(objectStore.get_LocaleName());
localized.set_LocalizedText("DocumentTest");
localizedList.add(localized);
subClass.set_DisplayNames(localizedList);
//optional : create property definition
Id propertyId = new Id("{2AC1F24D-2D69-4F9E-8780-0069F6D3A834}");
PropertyTemplate property = Factory.PropertyTemplate.fetchInstance(objectStore, propertyId, null);
PropertyDefinition propertyDefinition = property.createClassProperty();
PropertyDefinitionList propertyDefineList = subClass.get_PropertyDefinitions();
propertyDefineList.add(propertyDefinition);
subClass.set_PropertyDefinitions(propertyDefineList);
//
subClass.save(RefreshMode.REFRESH);
parentDocument.save(RefreshMode.REFRESH);
}
Nhận xét
Đăng nhận xét