📄 coboidplanesolidman.java
字号:
package operation;
import brgeometry.*;
import java.util.*;
import com.versant.fund.*;
import com.versant.trans.*;
import helper.ProBag;
import helper.rootMaker;
/**
* <p>Title: Broundary Rrepresentaion</p>
* <p>Description: 这是一个实现对于长方体操作的具体的类。
* 它实现了接口Manager提供了用户和数据库交互的基本操作</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: USTC</p>
* @author unascribed
* @version 1.0
*/
public class CoboidPlaneSolidMan
implements Manager {
TransSession session;
//首先,用“RootMaker”查找到rootmaker对象,然后调用该对象的方法产生一个新的root
rootMaker rm;
public CoboidPlaneSolidMan(TransSession session) {
this.session = session;
rm = (rootMaker) session.findRoot("Maker");
}
/* 增加一个长方体 */
public Solid create() {
try {
rm.addCuboidPlaneSolidNum();
//产生一个新的root;
String root = rm.CuboidPlaneSolidrootMaker();
System.out.println("the root of the newly created Cuboid is : " + root);
CuboidPlaneSolid cuboidPlaneSolid = new CuboidPlaneSolid();
cuboidPlaneSolid.setName(root);
//持久化
session.makeRoot(root, cuboidPlaneSolid);
session.commit();
//返回该对象的基类;
return cuboidPlaneSolid;
}
catch (VException exception) {
session.endSession();
//rootMaker 新产生的root与数据库中已经有的root重复
if (exception.getErrno() == Constants.EVJ_ROOTNAME_ALREADY_DEFINED)
System.out.println("Root name already exists");
//rootMaker不存在
if (exception.getErrno() == Constants.EVJ_ROOTNAME_DOES_NOT_EXIST) {
System.out.println("rootname does not exist");
rm = null;
}
else
throw exception;
return null;
}
}
//删除一个长方体
public void deleteByRoot(String root) {
try {
CuboidPlaneSolid cuboidPlaneSolid = (CuboidPlaneSolid) session.findRoot(
root);
//删除一个长方体
VEnumeration result;
RequireMan requireMan =new RequireMan(session );
result=requireMan.deepSelect( root,"Cuboid" );
while (result.hasMoreElements()) {
session.deleteObject(result.nextElement());
}
//删除这个长方体对应的root
session.deleteRoot(root);
//相应的rootmaker的值减少一;
rm.delCuboidPlaneSolidNum();
session.commit();
System.out.println("delete a CoboidPlaneSolid with name " + root);
}
catch (VException exception) {
session.endSession();
// Ignore error if root name does not exist
int err = exception.getErrno();
if (err != Constants.EVJ_ROOTNAME_DOES_NOT_EXIST) {
throw exception;
}
}
}
public Solid findByRoot(String root) {
try{
CuboidPlaneSolid cuboidPlaneSolid = (CuboidPlaneSolid) session.findRoot(
root);
session.commit();
return cuboidPlaneSolid;
}
catch (VException exception) {
// Ignore error if root name does not exist
int err = exception.getErrno();
if (err != Constants.EVJ_ROOTNAME_DOES_NOT_EXIST) {
throw exception;
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -