use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class ImplicitContextLoadHelper method loadPropertyTypeFromPreference.
/**
* DOC hcw Comment method "reloadPropertyType".
*
* @param element
* @param extraComposite
* @param languagePrefix
* @param elementParameter
*/
private static void loadPropertyTypeFromPreference(Element element, ExtraComposite extraComposite, String languagePrefix, IElementParameter elementParameter) {
String propertyType = (String) getPreferenceValue(languagePrefix, EParameterName.PROPERTY_TYPE, String.class);
String id = (String) getPreferenceValue(languagePrefix, EParameterName.REPOSITORY_PROPERTY_TYPE, String.class);
Connection repositoryConnection = null;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(id);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
repositoryConnection = ((ConnectionItem) item).getConnection();
} else {
repositoryConnection = null;
}
ChangeValuesFromRepository cmd1 = new ChangeValuesFromRepository(element, repositoryConnection, getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
propertyType);
ChangeValuesFromRepository cmd2 = new ChangeValuesFromRepository(element, repositoryConnection, getExtraParameterName(EParameterName.PROPERTY_TYPE) + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
id);
AbstractMultiPageTalendEditor part = (AbstractMultiPageTalendEditor) ((IProcess2) element).getEditor();
if (part instanceof AbstractMultiPageTalendEditor) {
Object adapter = (part).getTalendEditor().getAdapter(CommandStack.class);
if (adapter != null) {
CommandStack commandStack = ((CommandStack) adapter);
commandStack.execute(cmd1);
commandStack.execute(cmd2);
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class JobSettingsView method onPropertiesChanged.
@Override
public void onPropertiesChanged(Map<String, Object> maps) {
if (maps == null || maps.isEmpty()) {
return;
}
Object obj = maps.get(IJobSettingsView.JOBTYPE_CHANGED);
if (obj instanceof IRepositoryViewObject) {
String type = null;
IRepositoryViewObject repositoryObject = (IRepositoryViewObject) obj;
// opened job needn't to change the title
if (!(obj instanceof IProcess2)) {
Property property = repositoryObject.getProperty();
if (property != null) {
Item item = property.getItem();
if (item != null) {
ERepositoryObjectType repositoryObjectType = ERepositoryObjectType.getItemType(item);
if (repositoryObjectType == ERepositoryObjectType.PROCESS) {
type = getViewNameLable();
} else if (repositoryObjectType != null) {
type = repositoryObjectType.getLabel();
}
}
}
}
Image image = getImage(repositoryObject);
if (image != null && image.isDisposed()) {
image = null;
}
if (type == null) {
super.setTitleImage(image);
tabFactory.setTitleImage(image);
} else {
String title = repositoryObject.getLabel();
if (allowVerchange) {
if (repositoryObject.getVersion() != null) {
//$NON-NLS-1$
title = repositoryObject.getLabel() + " " + repositoryObject.getVersion();
}
}
setPartName(type + SEPARATOR + title, image);
}
}
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class RowGenProcessMain method getProcess.
private void getProcess() {
initPerlArray();
this.component.setNumber(number);
if (component.getProcess() instanceof IProcess2) {
// get current job context manager.
jobContextManager = component.getProcess().getContextManager();
}
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setLabel(PREVIEW + "_RowGenerator2");
//$NON-NLS-1$
property.setId(PREVIEW + "_RowGenerator2");
proc = new RowGenProcess(property, component);
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class JobErrorsChecker method checkLastGenerationHasCompilationError.
public static void checkLastGenerationHasCompilationError(boolean updateProblemsView) throws ProcessorException {
if (updateProblemsView && CommonsPlugin.isHeadless()) {
updateProblemsView = false;
}
boolean hasError = false;
boolean isJob = true;
Item item = null;
final IProxyRepositoryFactory proxyRepositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
Integer line = null;
String errorMessage = null;
try {
for (JobInfo jobInfo : LastGenerationInfo.getInstance().getLastGeneratedjobs()) {
if (jobInfo.isTestContainer()) {
continue;
}
item = null;
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;
}
IFile file = synchronizer.getFile(item);
if (file == null) {
return;
}
// check other java files related to the job . example : spark job will generate several java file for
// one job
final IResource[] members = file.getParent().members();
for (IResource member : members) {
if (member instanceof IFile && "java".equals(member.getFileExtension())) {
IMarker[] markers = ((IFile) member).findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
for (IMarker marker : markers) {
Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
String message = (String) marker.getAttribute(IMarker.MESSAGE);
Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
if (lineNr != null && message != null && severity != null && start != null && end != null) {
switch(severity) {
case IMarker.SEVERITY_ERROR:
hasError = true;
line = lineNr;
errorMessage = message;
break;
default:
break;
}
}
}
}
}
if (updateProblemsView) {
Problems.addRoutineFile(file, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
}
if (hasError) {
break;
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (hasError && item != null) {
if (isJob) {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
} else {
throw new ProcessorException(//$NON-NLS-1$
Messages.getString("CamelJobErrorsChecker_compile_errors") + " " + '\n' + Messages.getString("JobErrorsChecker_compile_error_message", item.getProperty().getLabel()) + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
'\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + errorMessage + //$NON-NLS-1$
'\n' + //$NON-NLS-1$
Messages.getString("JobErrorsChecker_compile_error_jvmmessage"));
}
}
// if no error for job, check codes.
checkRoutinesCompilationError();
}
use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.
the class StandAloneTalendJavaEditor method resetItem.
public void resetItem() throws PersistenceException {
if (item.getProperty().eResource() == null || item.eResource() == null) {
IRepositoryService service = CoreRuntimePlugin.getInstance().getRepositoryService();
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
//
// Property updated = factory.getUptodateProperty(getItem().getProperty());
Property updatedProperty = null;
try {
factory.initialize();
IRepositoryViewObject repositoryViewObject = factory.getLastVersion(new Project(ProjectManager.getInstance().getProject(item.getProperty().getItem())), item.getProperty().getId());
if (repositoryViewObject != null) {
updatedProperty = repositoryViewObject.getProperty();
item = (FileItem) updatedProperty.getItem();
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
Aggregations