use of cbit.image.VCImageInfo in project vcell by virtualcell.
the class DatabaseWindowManager method accessPermissions.
/**
* Insert the method's description here.
* Creation date: (5/14/2004 5:35:55 PM)
*/
public void accessPermissions(final Component requester, final VersionInfo selectedVersionInfo) {
final GroupAccess groupAccess = selectedVersionInfo.getVersion().getGroupAccess();
final DocumentManager docManager = getRequestManager().getDocumentManager();
AsynchClientTask task1 = new AsynchClientTask("show dialog", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
getAclEditor().clearACLList();
getAclEditor().setACLState(new ACLEditor.ACLState(groupAccess));
Object choice = showAccessPermissionDialog(getAclEditor(), requester);
if (choice != null) {
hashTable.put("choice", choice);
}
}
};
AsynchClientTask task2 = new AsynchClientTask("access permission", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Object choice = hashTable.get("choice");
if (choice != null && choice.equals("OK")) {
ACLEditor.ACLState aclState = getAclEditor().getACLState();
if (aclState != null) {
if (aclState.isAccessPrivate() || (aclState.getAccessList() != null && aclState.getAccessList().length == 0)) {
VersionInfo vInfo = null;
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.setGroupPrivate((BioModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.setGroupPrivate((MathModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.setGroupPrivate((GeometryInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.setGroupPrivate((VCImageInfo) selectedVersionInfo);
}
} else if (aclState.isAccessPublic()) {
VersionInfo vInfo = null;
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.setGroupPublic((BioModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.setGroupPublic((MathModelInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.setGroupPublic((GeometryInfo) selectedVersionInfo);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.setGroupPublic((VCImageInfo) selectedVersionInfo);
}
} else {
String[] aclUserNames = aclState.getAccessList();
String[] originalGroupAccesNames = new String[0];
// Turn User[] into String[]
if (groupAccess instanceof GroupAccessSome) {
GroupAccessSome gas = (GroupAccessSome) groupAccess;
User[] originalUsers = gas.getNormalGroupMembers();
for (int i = 0; i < originalUsers.length; i += 1) {
originalGroupAccesNames = (String[]) BeanUtils.addElement(originalGroupAccesNames, originalUsers[i].getName());
}
}
// Determine users needing adding
String[] needToAddUsers = new String[0];
for (int i = 0; i < aclUserNames.length; i += 1) {
if (!BeanUtils.arrayContains(originalGroupAccesNames, aclUserNames[i])) {
System.out.println("Added user=" + aclUserNames[i]);
needToAddUsers = (String[]) BeanUtils.addElement(needToAddUsers, aclUserNames[i]);
}
}
// Determine users needing removing
String[] needToRemoveUsers = new String[0];
for (int i = 0; i < originalGroupAccesNames.length; i += 1) {
if (!BeanUtils.arrayContains(aclUserNames, originalGroupAccesNames[i])) {
System.out.println("Removed user=" + originalGroupAccesNames[i]);
needToRemoveUsers = (String[]) BeanUtils.addElement(needToRemoveUsers, originalGroupAccesNames[i]);
}
}
VersionInfo vInfo = null;
String errorNames = "";
// Add Users to Group Access List
for (int i = 0; i < needToAddUsers.length; i++) {
try {
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.addUserToGroup((BioModelInfo) selectedVersionInfo, needToAddUsers[i]);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.addUserToGroup((MathModelInfo) selectedVersionInfo, needToAddUsers[i]);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.addUserToGroup((GeometryInfo) selectedVersionInfo, needToAddUsers[i]);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.addUserToGroup((VCImageInfo) selectedVersionInfo, needToAddUsers[i]);
}
} catch (ObjectNotFoundException e) {
errorNames += "Error changing permissions.\n" + selectedVersionInfo.getVersionType().getTypeName() + " \"" + selectedVersionInfo.getVersion().getName() + "\" edition (" + selectedVersionInfo.getVersion().getDate() + ")\nnot found, " + "your model list may be out of date, please go to menu Server->Reconnect to refresh the model list" + "\n";
break;
} catch (DataAccessException e) {
errorNames += "Error adding user '" + needToAddUsers[i] + "' : " + e.getMessage() + "\n";
}
}
// Remove users from Group Access List
for (int i = 0; i < needToRemoveUsers.length; i++) {
try {
if (selectedVersionInfo instanceof BioModelInfo) {
vInfo = docManager.removeUserFromGroup((BioModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
} else if (selectedVersionInfo instanceof MathModelInfo) {
vInfo = docManager.removeUserFromGroup((MathModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
} else if (selectedVersionInfo instanceof GeometryInfo) {
vInfo = docManager.removeUserFromGroup((GeometryInfo) selectedVersionInfo, needToRemoveUsers[i]);
} else if (selectedVersionInfo instanceof VCImageInfo) {
vInfo = docManager.removeUserFromGroup((VCImageInfo) selectedVersionInfo, needToRemoveUsers[i]);
}
} catch (DataAccessException e) {
errorNames += "Error Removing user '" + needToRemoveUsers[i] + "'\n -----" + e.getMessage() + "\n";
}
}
if (errorNames.length() > 0) {
if (DatabaseWindowManager.this.getComponent() != null) {
PopupGenerator.showErrorDialog(DatabaseWindowManager.this, errorNames);
} else {
DialogUtils.showErrorDialog(requester, errorNames);
}
accessPermissions(requester, selectedVersionInfo);
}
}
}
}
}
};
ClientTaskDispatcher.dispatch(requester, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.image.VCImageInfo in project vcell by virtualcell.
the class ClientDocumentManager method addUserToGroup.
/**
* Insert the method's description here.
* Creation date: (11/28/00 5:43:44 PM)
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
public VCImageInfo addUserToGroup(VCImageInfo imageInfo, String userToAdd) throws DataAccessException {
try {
//
// publish from database
//
VCImageInfo newImageInfo = (VCImageInfo) addUserToGroup0(imageInfo, VersionableType.VCImage, imgInfoHash, userToAdd);
//
// delete Image from cache
//
xmlHash.remove(imageInfo.getVersion().getVersionKey());
fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, imageInfo, newImageInfo));
return newImageInfo;
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
throw new DataAccessException(e.getMessage());
}
}
use of cbit.image.VCImageInfo in project vcell by virtualcell.
the class ClientDocumentManager method saveAsNew.
/**
* Insert the method's description here.
* Creation date: (2/5/01 4:58:40 PM)
*/
public VCImage saveAsNew(VCImage vcImage, java.lang.String newName) throws DataAccessException {
try {
String vcImageXML = null;
try {
vcImageXML = XmlHelper.imageToXML(vcImage);
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage());
}
String savedVCImageXML = sessionManager.getUserMetaDbServer().saveVCImageAs(new BigString(vcImageXML), newName).toString();
VCImage savedVCImage = null;
try {
savedVCImage = XmlHelper.XMLToImage(savedVCImageXML);
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage());
}
savedVCImage.refreshDependencies();
KeyValue savedKey = savedVCImage.getVersion().getVersionKey();
if (xmlHash.get(savedKey) == null) {
xmlHash.put(savedKey, savedVCImageXML);
}
try {
ISize size = new ISize(savedVCImage.getNumX(), savedVCImage.getNumY(), savedVCImage.getNumZ());
GIFImage browseData = BrowseImage.makeBrowseGIFImage(savedVCImage);
VCImageInfo savedVCImageInfo = new VCImageInfo(savedVCImage.getVersion(), size, savedVCImage.getExtent(), browseData, VCellSoftwareVersion.fromSystemProperty());
imgInfoHash.put(savedKey, savedVCImageInfo);
fireDatabaseInsert(new DatabaseEvent(this, DatabaseEvent.INSERT, null, savedVCImageInfo));
} catch (Exception e) {
e.printStackTrace(System.out);
}
return savedVCImage;
} catch (RemoteProxyException e) {
e.printStackTrace(System.out);
throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
}
}
use of cbit.image.VCImageInfo in project vcell by virtualcell.
the class ClientDocumentManager method setGroupPublic.
/**
* Insert the method's description here.
* Creation date: (11/28/00 5:43:44 PM)
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
public VCImageInfo setGroupPublic(VCImageInfo imageInfo) throws DataAccessException {
try {
//
// publish from database
//
VCImageInfo newImageInfo = (VCImageInfo) setGroupPublic0(imageInfo, VersionableType.VCImage, imgInfoHash);
//
// delete Image from cache
//
xmlHash.remove(imageInfo.getVersion().getVersionKey());
fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, imageInfo, newImageInfo));
return newImageInfo;
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
throw new DataAccessException(e.getMessage());
}
}
use of cbit.image.VCImageInfo in project vcell by virtualcell.
the class ClientDocumentManager method updateGeometryRelatedHashes.
private void updateGeometryRelatedHashes(Geometry savedGeometry) {
if (savedGeometry == null || (savedGeometry.getVersion() != null && geoInfoHash.get(savedGeometry.getVersion().getVersionKey()) != null)) {
return;
}
KeyValue imageRef = (savedGeometry.getGeometrySpec().getImage() != null) ? (savedGeometry.getGeometrySpec().getImage().getKey()) : (null);
if (imageRef != null && imgInfoHash.get(imageRef) == null) {
VCImage savedVCImage = savedGeometry.getGeometrySpec().getImage();
ISize size = new ISize(savedVCImage.getNumX(), savedVCImage.getNumY(), savedVCImage.getNumZ());
VCImageInfo savedVCImageInfo = new VCImageInfo(savedVCImage.getVersion(), size, savedVCImage.getExtent(), null, VCellSoftwareVersion.fromSystemProperty());
imgInfoHash.put(savedVCImage.getVersion().getVersionKey(), savedVCImageInfo);
}
GeometryInfo savedGeometryInfo = new GeometryInfo(savedGeometry.getVersion(), savedGeometry.getDimension(), savedGeometry.getExtent(), savedGeometry.getOrigin(), imageRef, VCellSoftwareVersion.fromSystemProperty());
geoInfoHash.put(savedGeometry.getVersion().getVersionKey(), savedGeometryInfo);
fireDatabaseInsert(new DatabaseEvent(this, DatabaseEvent.INSERT, null, geoInfoHash.get(savedGeometry.getVersion().getVersionKey())));
}
Aggregations