use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class GuessSchemaProcess method getNewmockProperty.
public static Property getNewmockProperty() {
Property mockProperty = PropertiesFactory.eINSTANCE.createProperty();
mockProperty.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
mockProperty.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
mockProperty.setStatusCode("");
//$NON-NLS-1$
mockProperty.setId("ID");
mockProperty.setLabel(DEFAULT_JOB_NAME);
return mockProperty;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class GuessSchemaController method useMockJob.
private void useMockJob() {
/*
* get the select node,it's the input node of the process. then transfer selected context varriable to
* openContextChooseDialog, added by hyWang
*/
final IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
final Shell parentShell = this.composite.getShell();
final Node inputNode = (Node) this.curParameter.getElement();
if (connParameters == null) {
initConnectionParameters();
}
final String tmpMemoSql = this.memoSQL;
final DatabaseConnection connt = TracesConnectionUtils.createConnection(connParameters);
IMetadataConnection iMetadataConnection = null;
boolean isStatus = false;
try {
if (connt != null) {
iMetadataConnection = ConvertionHelper.convert(connt);
isStatus = checkConnection(iMetadataConnection);
}
if (isStatus) {
if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(iMetadataConnection.getDbType())) {
info = new DbInfo(iMetadataConnection.getDbType(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getUrl(), iMetadataConnection.getDriverClass(), iMetadataConnection.getDriverJarPath(), iMetadataConnection.getAdditionalParams());
} else if (EDatabaseTypeName.HIVE.getDisplayName().equals(iMetadataConnection.getDbType())) {
String jobTracker = TalendTextUtils.removeQuotes(String.valueOf(iMetadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL)));
String nameNode = TalendTextUtils.removeQuotes(String.valueOf(iMetadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL)));
String thrifturi = null;
if (HiveModeInfo.get(iMetadataConnection.getDbVersionString()) == HiveModeInfo.EMBEDDED) {
thrifturi = "thrift://" + iMetadataConnection.getServerName() + ":" + iMetadataConnection.getPort();
}
info = new DbInfo(iMetadataConnection.getDbType(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getUrl(), jobTracker, nameNode, thrifturi, iMetadataConnection.getDriverJarPath());
String hiveServerVersion = String.valueOf(iMetadataConnection.getParameter(ConnParameterKeys.HIVE_SERVER_VERSION));
//$NON-NLS-1$
String driverClass = "";
if (HiveServerVersionInfo.HIVE_SERVER_2.getKey().equals(hiveServerVersion)) {
driverClass = EDatabase4DriverClassName.HIVE2.getDriverClass();
} else {
driverClass = EDatabase4DriverClassName.HIVE.getDriverClass();
}
info.setDriverClassName(driverClass);
} else {
info = new DbInfo(iMetadataConnection.getDbType(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getUrl(), iMetadataConnection.getDriverJarPath());
}
final Property property = GuessSchemaProcess.getNewmockProperty();
List<IContext> allcontexts = inputNode.getProcess().getContextManager().getListContext();
OpenContextChooseComboDialog dialog = new OpenContextChooseComboDialog(parentShell, allcontexts);
dialog.create();
dialog.getShell().setText(CONTEXT_CHOOSE_DIALOG_TITLE);
IContext selectContext = null;
// job only have defoult context,or the query isn't context mode
if (allcontexts.size() == 1 || TalendTextUtils.isCommonString(tmpMemoSql)) {
selectContext = inputNode.getProcess().getContextManager().getDefaultContext();
} else if (Window.OK == dialog.open()) {
selectContext = dialog.getSelectedContext();
}
final IContext context = selectContext;
if (context != null) {
//
final ProgressMonitorDialog pmd = new ProgressMonitorDialog(this.composite.getShell());
pmd.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
runShadowProcess(property, inputNode, context, switchParam);
}
});
}
});
}
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
String pid = "org.talend.sqlbuilder";
//$NON-NLS-1$
String mainMsg = Messages.getString("GuessSchemaController.connectionFailed");
ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connParameters.getConnectionComment());
if (dialog.getCodeOfButton() == Window.OK) {
openParamemerDialog(composite.getShell(), part.getProcess().getContextManager());
}
}
});
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
// else {
// try {
// pmd2.run(true, true, new IRunnableWithProgress() {
// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// Display.getDefault().asyncExec(new Runnable() {
//
// public void run() {
// String pid = SqlBuilderPlugin.PLUGIN_ID;
// String mainMsg = Messages.getString("GuessSchemaController.connectionFailed"); //$NON-NLS-1$
// ErrorDialogWithDetailAreaAndContinueButton dialog = new ErrorDialogWithDetailAreaAndContinueButton(composite
// .getShell(), pid, mainMsg, connParameters.getConnectionComment());
// if (dialog.getCodeOfButton() == Window.OK) {
// openParamemerDialog(composite.getShell(), part.getTalendEditor().getProcess().getContextManager());
// }
// }
// });
// }
// });
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class GenerateGrammarController method persistInRoutine.
/**
* Persist item in routines
*
* DOC ytao Comment method "persistInRoutine".
*
* @param path, sub folder named with job id
* @param label, java file name without suffix
* @param initFile, File handler
* @param name, job id as package name
* @return
*/
private RoutineItem persistInRoutine(IPath inFolder, File fileToFill, String label) {
// item property to be set
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
property.setStatusCode("");
// Label must match pattern ^[a-zA-Z\_]+[a-zA-Z0-9\_]*$
// Must be composed with JAVA_PORJECT_NAME + JOB NAME + COMPONENT NAME,
// since all projects share with the same routines
property.setLabel(label);
// add properties to item
RoutineItem routineItem = PropertiesFactory.eINSTANCE.createRoutineItem();
routineItem.setProperty(property);
// get the content of java file as byte array.
ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
InputStream stream = null;
try {
stream = new FileInputStream(fileToFill);
byte[] bytes = new byte[stream.available()];
stream.read(bytes);
byteArray.setInnerContent(bytes);
} catch (IOException e) {
ExceptionHandler.process(e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
routineItem.setContent(byteArray);
// persist item in routines
IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
try {
property.setId(repositoryFactory.getNextId());
// create folder with name job id: routines/JOBID (seems from TOS)
repositoryFactory.createParentFoldersRecursively(ERepositoryObjectType.getItemType(routineItem), inFolder);
// add the item
repositoryFactory.create(routineItem, inFolder);
} catch (Exception e) {
ExceptionHandler.process(e);
}
return routineItem;
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class OpenRepositoryJobHierarchyAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
RepositoryNode node = (RepositoryNode) obj;
Property property = (Property) node.getObject().getProperty();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
if (node.getObject() instanceof IRepositoryObject) {
IRepositoryObject iobject = (IRepositoryObject) node.getObject();
iobject.setProperty(updatedProperty);
}
Assert.isTrue(property.getItem() instanceof ProcessItem);
// TODO should use a fake Process here to replace the real Process.
// Process loadedProcess = new Process(property);
// loadedProcess.loadXmlFile();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Process loadedProcess = (Process) designerCoreService.getProcessFromProcessItem((ProcessItem) updatedProperty.getItem());
OpenJobHierarchyAction openAction = new OpenJobHierarchyAction(this.getViewPart());
openAction.run(loadedProcess);
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class JobErrorsChecker method getErrors.
public static List<IContainerEntry> getErrors() {
List<IContainerEntry> input = new ArrayList<IContainerEntry>();
try {
Item item = null;
IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Set<String> jobIds = new HashSet<String>();
for (JobInfo jobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
// TDI-28198:get right process item no matter the job open or close
List<IRepositoryViewObject> allVersions = proxyRepositoryFactory.getAllVersion(jobInfo.getJobId());
for (IRepositoryViewObject repositoryObject2 : allVersions) {
Property property2 = repositoryObject2.getProperty();
if (jobInfo.getJobVersion().equals(property2.getVersion())) {
item = property2.getItem();
break;
}
}
if (item == null) {
continue;
}
// get source file
IFile sourceFile = synchronizer.getFile(item);
if (sourceFile == null) {
continue;
}
jobIds.add(item.getProperty().getId());
// Property property = process.getProperty();
Problems.addJobRoutineFile(sourceFile, ProblemType.JOB, item, true);
}
if (!CommonsPlugin.isHeadless()) {
List<IRepositoryViewObject> routinesObjects = proxyRepositoryFactory.getAll(ERepositoryObjectType.ROUTINES, false);
Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(), LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
if (routinesObjects != null) {
for (IRepositoryViewObject obj : routinesObjects) {
Property property = obj.getProperty();
if (dependentRoutines.contains(property.getLabel())) {
Item routinesitem = property.getItem();
IFile routineFile = synchronizer.getFile(routinesitem);
Problems.addJobRoutineFile(routineFile, ProblemType.ROUTINE, routinesitem, true);
} else {
Problems.clearAllComliationError(property.getLabel());
}
}
}
}
Problems.refreshProblemTreeView();
// collect error
List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
ErrorDetailTreeBuilder builder = new ErrorDetailTreeBuilder();
input.addAll(builder.createTreeInput(errors, jobIds));
} catch (Exception e) {
ExceptionHandler.process(e);
}
return input;
}
Aggregations