示例#1
0
 public void setInfo(TimetableInfo info, TimetableInfoFileProxy proxy) throws Exception {
   if (info.saveToFile()) {
     FileInfo fInfo = new FileInfo();
     String defName = null;
     if (getDefinition() != null) {
       defName = getDefinition().getName();
     } else {
       defName = info.getClass().getName();
       if (defName.indexOf('.') >= 0) defName = defName.substring(defName.lastIndexOf('.') + 1);
     }
     fInfo.setName(defName + "_" + generateId() + ".zxml");
     fInfo.saveInfo(info, proxy);
     info = fInfo;
   }
   Document document = DocumentHelper.createDocument();
   Element root = document.addElement(info.getClass().getName());
   info.save(root);
   setValue(document);
   setCached(getUniqueId(), info);
 }
示例#2
0
 public void delete(org.hibernate.Session hibSession, TimetableInfoFileProxy proxy)
     throws Exception {
   if (getValue() != null) {
     Element root = getValue().getRootElement();
     Class infoClass = null;
     try {
       infoClass = Class.forName(root.getName());
     } catch (ClassNotFoundException ex) {
       infoClass = Class.forName(getDefinition().getImplementation());
     }
     TimetableInfo info =
         (TimetableInfo) infoClass.getConstructor(new Class[] {}).newInstance(new Object[] {});
     if (info instanceof FileInfo) {
       info.load(root);
       ((FileInfo) info).deleteFile(proxy);
     }
   }
   removeCached(getUniqueId());
   hibSession.delete(this);
 }