use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class NewRoutineWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
try {
updateRoutineContent();
property.setId(repositoryFactory.getNextId());
//changed by hqzhang for TDI-19527, label=displayName
property.setLabel(property.getDisplayName());
repositoryFactory.create(routineItem, mainPage.getDestinationPath());
} catch (PersistenceException e) {
//$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openError(getShell(), Messages.getString("NewProcessWizard.failureTitle"), "");
ExceptionHandler.process(e);
}
return routineItem != null;
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tesb-studio-se by Talend.
the class ServiceMetadataDialog method okPressed.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
EMap<String, String> props = serviceConnection.getAdditionalInfo();
if (props != null) {
props.put(USE_SAM, Boolean.toString(isUseSam()));
props.put(USE_SL, Boolean.toString(isUseSL()));
props.put(SECURITY_BASIC, Boolean.toString(getSecurityBasic()));
props.put(SECURITY_SAML, Boolean.toString(getSecuritySAML()));
props.put(AUTHORIZATION, Boolean.toString(getAuthorization()));
props.put(ENCRYPTION, Boolean.toString(getEncryption()));
props.put(USE_SERVICE_REGISTRY, Boolean.toString(getUseServiceRegistry()));
props.put(LOG_MESSAGES, Boolean.toString(isLogMessages()));
props.put(WSDL_SCHEMA_VALIDATION, Boolean.toString(isWsdlSchemaValidation()));
props.put(USE_BUSINESS_CORRELATION, Boolean.toString(useBusinessCorrelation));
if (isUseSL()) {
slCustomProperties = new HashMap<String, String>(customPropertiesTable.getPropertiesMap());
// remove old custom properties
List<String> props2delete = new ArrayList<String>();
for (String propKey : props.keySet()) {
if (propKey.startsWith(SL_CUSTOM_PROP_PREFIX)) {
props2delete.add(propKey);
}
}
for (String propKey : props2delete) {
props.removeKey(propKey);
}
// set new custom properties
for (Map.Entry<String, String> prop : slCustomProperties.entrySet()) {
props.put(SL_CUSTOM_PROP_PREFIX + prop.getKey(), prop.getValue());
}
}
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
factory.save(serviceItem);
} catch (PersistenceException e) {
e.printStackTrace();
}
super.okPressed();
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tesb-studio-se by Talend.
the class OpenWSDLPage method finish.
public boolean finish() {
// changed by hqzhang for TDI-19527, label=displayName
final String label = item.getProperty().getDisplayName();
item.getProperty().setLabel(label);
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(final IProgressMonitor monitor) throws CoreException {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
item.setConnection(ServicesFactory.eINSTANCE.createServiceConnection());
if (creation) {
item.getProperty().setId(factory.getNextId());
factory.create(item, getDestinationPath());
repositoryNode = new RepositoryNode(new RepositoryViewObject(item.getProperty()), repositoryNode.getParent(), ENodeType.REPOSITORY_ELEMENT);
}
((ServiceConnection) item.getConnection()).setWSDLPath(path);
((ServiceConnection) item.getConnection()).getServicePort().clear();
final IFile fileWsdl = WSDLUtils.getWsdlFile(item);
final InputStream is;
if (null == path) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// create new WSDL file from template
TemplateProcessor.processTemplate("DATA_SERVICE_WSDL", Collections.singletonMap("serviceName", (Object) label), baos, getClass().getResourceAsStream(TEMPLATE_SERVICE_WSDL));
is = new ByteArrayInputStream(baos.toByteArray());
} else {
//$NON-NLS-1$
String filenameTemplate = item.getProperty().getLabel() + '_' + item.getProperty().getVersion() + ".%d.wsdl";
Map<String, InputStream> wsdls = new WSDLLoader().load(path, filenameTemplate);
is = wsdls.remove(WSDLLoader.DEFAULT_FILENAME);
for (Map.Entry<String, InputStream> wsdl : wsdls.entrySet()) {
String filename = wsdl.getKey();
IFile importedWsdl = fileWsdl.getParent().getFile(new Path(filename));
if (!importedWsdl.exists()) {
importedWsdl.create(wsdl.getValue(), true, monitor);
} else {
importedWsdl.setContents(wsdl.getValue(), 0, monitor);
}
createReferenceResources(filename.substring(filename.lastIndexOf('.', filename.lastIndexOf('.') - 1) + 1));
}
}
// store WSDL in service
if (!fileWsdl.exists()) {
fileWsdl.create(is, true, monitor);
} else {
fileWsdl.setContents(is, 0, monitor);
}
// create reference to wsdl
//$NON-NLS-1$
createReferenceResources("wsdl");
// path
definition = WSDLUtils.getDefinition(fileWsdl);
populateModelFromWsdl(factory, definition, item, repositoryNode);
factory.save(item);
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
} catch (Exception e) {
//delete the node if any exception during the creation
if (creation) {
try {
factory.save(item);
factory.deleteObjectPhysical(repositoryNode.getObject());
} catch (PersistenceException e1) {
throw getCoreException("WDSL creation failed", e1);
}
}
//throw the exception
if (e instanceof CoreException) {
throw (CoreException) e;
}
if (e instanceof InvocationTargetException) {
throw getCoreException("WDSL creation failed", e.getCause());
}
throw getCoreException("WDSL creation failed", e);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
// we use the workspace scheduling rule to lock all
ISchedulingRule schedulingRule = workspace.getRoot();
// workspace modifications during the run.
// the update of the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
// open wsdl editor
OpenWSDLEditorAction action = new OpenWSDLEditorAction();
action.setServiceItem(item);
action.run();
// import schemas if required
if (checkImport.isVisible() && checkImport.getSelection() && null != definition) {
PublishMetadataRunnable publishMetadataRunnable = new PublishMetadataRunnable(definition, getShell());
try {
getContainer().run(true, true, publishMetadataRunnable);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
String message = (null != cause.getMessage()) ? cause.getMessage() : cause.getClass().getName();
setErrorMessage("Populate schema to repository: " + message);
return false;
} catch (InterruptedException e) {
return false;
}
}
return true;
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tesb-studio-se by Talend.
the class OpenJobAction method removeReferenecJobId.
protected static void removeReferenecJobId(IRepositoryNode node) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
String parentPortName = node.getParent().getObject().getLabel();
ServiceItem serviceItem = (ServiceItem) node.getParent().getParent().getObject().getProperty().getItem();
List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort port : listPort) {
if (port.getName().equals(parentPortName)) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getLabel().equals(node.getObject().getLabel())) {
operation.setReferenceJobId(null);
operation.setLabel(operation.getName());
factory.save(node.getObject().getProperty().getItem());
}
}
break;
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.
the class EditQueriesAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
canWork = false;
}
if (canWork) {
Object o = selection.getFirstElement();
repositoryNode = (RepositoryNode) o;
switch(repositoryNode.getType()) {
case REPOSITORY_ELEMENT:
if (repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED || repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
canWork = false;
}
// Studio does not support this action for impala, TBD-3827.
if (!isUnderDBConnection(repositoryNode)) {
canWork = false;
}
if (repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CONNECTIONS && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_QUERY && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_TABLE) {
canWork = false;
} else {
// for cdc
if (PluginChecker.isCDCPluginLoaded()) {
ICDCProviderService cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
if (cdcService != null && cdcService.isSubscriberTableNode(repositoryNode)) {
canWork = false;
break;
}
}
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
if (!repFactory.isPotentiallyEditable(repositoryNode.getObject())) {
canWork = false;
break;
}
}
if (canWork) {
Item item = repositoryNode.getObject().getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
DatabaseConnection dbConn = (DatabaseConnection) dbItem.getConnection();
String dbType = dbConn.getDatabaseType();
if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.HBASE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.MAPRDB.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.IMPALA.getXmlName().equalsIgnoreCase(dbType)) {
canWork = false;
break;
}
}
}
break;
default:
canWork = false;
}
if (canWork && (!ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
canWork = false;
}
}
setEnabled(canWork);
}
Aggregations