You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
5.1 KiB
127 lines
5.1 KiB
package com.connor.jd.plm.action;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import com.connor.jd.plm.utils.JDMethodUtil;
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
import com.teamcenter.rac.kernel.TCProperty;
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
public class DeleteItemRevisionAction extends AbstractAIFAction {
|
|
private AbstractAIFApplication app;
|
|
|
|
public DeleteItemRevisionAction(AbstractAIFApplication arg0, String arg1) {
|
|
super(arg0, arg1);
|
|
this.app = arg0;
|
|
// TODO Auto-generated constructor stub
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
// TODO Auto-generated method stub
|
|
TCSession session = (TCSession) app.getSession();
|
|
InterfaceAIFComponent[] targets = app.getTargetComponents();
|
|
String[] allow = JDMethodUtil.getPrefStrArray("connor_wl_type", session);
|
|
String[] allow2 = JDMethodUtil.getPrefStrArray("connor_tz_type", session);
|
|
String[] allow3 = JDMethodUtil.getPrefStrArray("jd2_wltz_Revise_allow", session);
|
|
System.out.println("connor_wl_type===>" + Arrays.toString(allow));
|
|
System.out.println("connor_tz_type===>" + Arrays.toString(allow2));
|
|
System.out.println("jd2_wltz_Revise_allow===>" + Arrays.toString(allow3));
|
|
List<String> pref = Arrays.asList(allow);
|
|
List<String> pref2 = Arrays.asList(allow2);
|
|
List<String> pref3 = Arrays.asList(allow3);
|
|
for (InterfaceAIFComponent target : targets) {
|
|
System.out.println(target.getType());
|
|
if (target instanceof TCComponentItemRevision) {
|
|
if (!pref.contains(target.getType()) && !pref2.contains(target.getType())
|
|
&& !pref3.contains(target.getType())) {
|
|
try {
|
|
MessageBox.post(target.getProperty("object_string") + "¼È²»ÊÇÎïÁÏÒ²²»ÊÇͼֽ£¬²»Ö´ÐÐɾ³ý", "Ìáʾ",
|
|
MessageBox.WARNING);
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
return;
|
|
}
|
|
TCComponentItemRevision rev = (TCComponentItemRevision) target;
|
|
try {
|
|
String loginUser = session.getUser().getProperty("object_string");
|
|
// String owningUser = rev.getProperty("owning_user");
|
|
// System.out.println("loginUser===>" + loginUser);
|
|
// System.out.println("owningUser===>" + owningUser);
|
|
boolean[] isAccess = session.getTCAccessControlService().checkPrivileges(rev.getItem(),
|
|
new String[] { "WRITE", "DELETE" });
|
|
if (isAccess[0] && isAccess[1]) {
|
|
TCComponentItem item = rev.getItem();
|
|
TCComponent[] released = item.getReleasedItemRevisions();
|
|
for (TCComponent comp : released) {
|
|
if (comp.getUid().equals(rev.getUid())) {
|
|
MessageBox.post(target.getProperty("object_string") + "ÎÞ·¨É¾³ý£¬ÎïÁÏÒѾ·¢²¼", "Ìáʾ",
|
|
MessageBox.WARNING);
|
|
return;
|
|
}
|
|
}
|
|
session.getUserService().call("bs_bypass", new Object[] { true });
|
|
System.out.println("rev uid===>" + rev.getUid());
|
|
AIFComponentContext[] aifs = rev.whereReferenced();
|
|
for (AIFComponentContext aif : aifs) {
|
|
if (aif.getComponent() instanceof TCComponent) {
|
|
TCComponent temp = (TCComponent) aif.getComponent();
|
|
if (temp.getUid().equals(rev.getItem().getUid())) {
|
|
System.out.println("Ìø¹ý¶ÔÏó");
|
|
continue;
|
|
}
|
|
System.out.println("ÒýÓÃÕß===>" + temp.getProperty("onject_string"));
|
|
TCProperty[] tcProps = temp.getAllTCProperties();
|
|
for (TCProperty tcProp : tcProps) {
|
|
if (tcProp.isReferenceType()) {
|
|
if (tcProp.isNotArray()) {
|
|
if (tcProp.getReferenceValue() != null
|
|
&& tcProp.getReferenceValue().getUid().equals(rev.getUid())) {
|
|
System.out.println("¹ØÏµ===>" + tcProp.getPropertyName());
|
|
temp.cutOperation(tcProp.getPropertyName(), new TCComponent[] { rev });
|
|
}
|
|
} else {
|
|
TCComponent[] comps = tcProp.getReferenceValueArray();
|
|
for (TCComponent comp : comps) {
|
|
if (comp.getUid().equals(rev.getUid())) {
|
|
System.out.println("¹ØÏµ===>" + tcProp.getPropertyName());
|
|
temp.cutOperation(tcProp.getPropertyName(),
|
|
new TCComponent[] { rev });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// if (pref.contains(target.getType())) {
|
|
// rev.cutOperation("TC_Is_Represented_By", rev.getRelatedComponents("TC_Is_Represented_By"));
|
|
// } else {
|
|
// rev.cutOperation("representation_for", rev.getRelatedComponents("representation_for"));
|
|
// }
|
|
rev.delete();
|
|
session.getUserService().call("bs_bypass", new Object[] { false });
|
|
MessageBox.post("ɾ³ý³É¹¦", "Ìáʾ", MessageBox.WARNING);
|
|
} else {
|
|
MessageBox.post(target.getProperty("object_string") + "ÎÞÐ޸ĺÍɾ³ýȨÏÞ", "Ìáʾ", MessageBox.WARNING);
|
|
}
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|