use of org.talend.mdm.repository.model.mdmserverobject.WSRoleSpecificationInstanceE in project tmdm-studio-se by Talend.
the class AddBrowseItemsWizardR method modifyRolesWithAttachedBrowseItem.
@Override
protected void modifyRolesWithAttachedBrowseItem(String browseItem, List<Line> roles) {
for (Line line : roles) {
List<KeyValue> keyValues = line.keyValues;
String roleName = keyValues.get(0).value;
MDMServerObjectItem roleItem = RepositoryQueryService.findServerObjectItemByName(IServerObjectRepositoryType.TYPE_ROLE, roleName);
if (roleItem != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, roleItem.getProperty().getId(), roleItem.getMDMServerObject().getName());
}
if (roleItem != null) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
if (factory.isEditableAndLockIfPossible(roleItem)) {
WSRoleE role = ((WSRoleItem) roleItem).getWsRole();
for (WSRoleSpecificationE spec : role.getSpecification()) {
if (spec.getObjectType().equals("View")) {
// $NON-NLS-1$
EList<WSRoleSpecificationInstanceE> specInstance = spec.getInstance();
//
WSRoleSpecificationInstanceE newInstance = MdmserverobjectFactory.eINSTANCE.createWSRoleSpecificationInstanceE();
newInstance.setInstanceName(browseItem);
// $NON-NLS-1$
newInstance.setWritable(keyValues.get(1).value.equals("Read Only") ? false : true);
//
specInstance.add(newInstance);
//
break;
}
}
RepositoryResourceUtil.saveItem(roleItem);
}
try {
factory.unlock(roleItem);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
}
Aggregations