📄 squareplanesolidman.java
字号:
package operation;
import brgeometry.*;
import com.versant.trans.*;
import java.util.*;
import com.versant.fund.*;
import com.versant.trans.*;
import helper.ProBag;
import helper.rootMaker;
/**
* <p>Title: Broundary Rrepresentaion</p>
* <p>Description: 这是一个实现对于正方体操作的具体的类。</p>
* 它实现了接口Manager提供了用户和数据库交互的基本操作</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: USTC</p>
* @author unascribed
* @version 1.0
*/
public class SquarePlaneSolidMan
implements Manager {
TransSession session;
//首先,用“RootMaker”查找到rootmaker对象,然后调用该对象的方法产生一个新的root
rootMaker rm;
public SquarePlaneSolidMan(TransSession session) {
this.session = session;
rm = (rootMaker) session.findRoot("Maker");
}
/* 增加一个方体 */
public Solid create() {
try {
// rm = (rootMaker) session.findRoot("Maker");
//开始一个和数据库的Session
rm.addSquarePlaneSolidNum();
//产生一个新的root;
String root = rm.SquarePlaneSolidrootMaker();
System.out.println("the root of the newly created Cuboid is : " + root);
SquarePlaneSolid squarePlaneSolid = new SquarePlaneSolid();
squarePlaneSolid.setName(root);
//持久化
session.makeRoot(root, squarePlaneSolid);
session.commit();
//返回该对象的基类;
return squarePlaneSolid;
}
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 {
SquarePlaneSolid squarePlaneSolid = (SquarePlaneSolid) session.findRoot(
root);
VEnumeration result;
RequireMan requireMan =new RequireMan(session );
result=requireMan.deepSelect( root,"Cube" );
while (result.hasMoreElements()) {
session.deleteObject(result.nextElement());
}
// session.deleteObject(squarePlaneSolid);
session.deleteRoot(root);
rm.delSquarePlaneSolidNum();
session.commit();
System.out.println("delete a CoboidPlaneSolid with name " + root);
}
catch (VException exception) {
session.endSession();
int err = exception.getErrno();
if (err != Constants.EVJ_ROOTNAME_DOES_NOT_EXIST) {
throw exception;
}
}
}
public Solid findByRoot(String root) {
try {
SquarePlaneSolid squarePlaneSolid = (SquarePlaneSolid) session.findRoot(
root);
session.commit();
return squarePlaneSolid;
}
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;
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -