use of org.talend.repository.items.importexport.handlers.model.ImportItem in project tdi-studio-se by Talend.
the class JobDesignImportHandler method afterApplyMigrationTasks.
@Override
protected void afterApplyMigrationTasks(ImportItem importItem) throws Exception {
Item tmpItem = importItem.getItem();
if (tmpItem instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) tmpItem;
ParametersType paType = processItem.getProcess().getParameters();
boolean statsPSettingRemoved = false;
// for commanline import project setting
if (importItem.isRemoveProjectStatslog()) {
if (paType != null) {
//$NON-NLS-1$
String paramName = "STATANDLOG_USE_PROJECT_SETTINGS";
EList listParamType = paType.getElementParameter();
for (int j = 0; j < listParamType.size(); j++) {
ElementParameterType pType = (ElementParameterType) listParamType.get(j);
if (pType != null && paramName.equals(pType.getName())) {
pType.setValue(Boolean.FALSE.toString());
statsPSettingRemoved = true;
break;
}
}
}
}
// 14446: item apply project setting param if use project setting
String statslogUsePSetting = null;
String implicitUsePSetting = null;
if (paType != null) {
EList listParamType = paType.getElementParameter();
for (int j = 0; j < listParamType.size(); j++) {
ElementParameterType pType = (ElementParameterType) listParamType.get(j);
if (pType != null) {
if (!statsPSettingRemoved && "STATANDLOG_USE_PROJECT_SETTINGS".equals(pType.getName())) {
//$NON-NLS-1$
statslogUsePSetting = pType.getValue();
}
if ("IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(pType.getName())) {
//$NON-NLS-1$
implicitUsePSetting = pType.getValue();
}
if (statsPSettingRemoved && implicitUsePSetting != null || !statsPSettingRemoved && implicitUsePSetting != null && statslogUsePSetting != null) {
break;
}
}
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
if (statslogUsePSetting != null && Boolean.parseBoolean(statslogUsePSetting)) {
//$NON-NLS-1$
designerCoreService.reloadParamFromProjectSettings(paType, "STATANDLOG_USE_PROJECT_SETTINGS");
}
if (implicitUsePSetting != null && Boolean.parseBoolean(implicitUsePSetting)) {
//$NON-NLS-1$
designerCoreService.reloadParamFromProjectSettings(paType, "IMPLICITCONTEXT_USE_PROJECT_SETTINGS");
}
}
}
}
use of org.talend.repository.items.importexport.handlers.model.ImportItem in project tdi-studio-se by Talend.
the class SqlTemplateImportHandler method isValidSystemItem.
@Override
public boolean isValidSystemItem(ImportItem importItem) {
boolean valid = super.valid(importItem);
if (!valid) {
return false;
}
Item item = importItem.getItem();
if (item instanceof SQLPatternItem) {
if (isSystemItem(item)) {
return true;
}
}
return false;
}
use of org.talend.repository.items.importexport.handlers.model.ImportItem in project tdi-studio-se by Talend.
the class TalendImportUtil method populateItems.
private static List<ImportItem> populateItems(final ImportExportHandlersManager importManager, final ResourcesManager resourcesManager, IProgressMonitor monitor, final boolean overwrite) {
List<ImportItem> selectedItemRecords = new ArrayList<ImportItem>();
nodesBuilder.clear();
if (resourcesManager != null) {
// if resource is not init successfully.
try {
// List<ImportItem> items = importManager.populateImportingItems(resourcesManager, overwrite,
// new NullProgressMonitor(), true);
List<ImportItem> items = importManager.populateImportingItems(resourcesManager, overwrite, monitor, true);
nodesBuilder.addItems(items);
} catch (Exception e) {
CommonExceptionHandler.process(e);
}
}
ImportItem[] allImportItemRecords = nodesBuilder.getAllImportItemRecords();
selectedItemRecords.addAll(Arrays.asList(allImportItemRecords));
Iterator<ImportItem> itemIterator = selectedItemRecords.iterator();
while (itemIterator.hasNext()) {
ImportItem item = itemIterator.next();
if (!item.isValid()) {
itemIterator.remove();
}
}
return selectedItemRecords;
}
use of org.talend.repository.items.importexport.handlers.model.ImportItem in project tdi-studio-se by Talend.
the class ImportDemoProjectItemsPage method clearOverWriteErrorMessages.
private void clearOverWriteErrorMessages(List<ImportItem> projectRecords, boolean overwrite) {
if (overwrite) {
String overWriteErrorMessage = Messages.getString("RepositoryUtil.nameUsed").trim();
List<ImportItem> overWriteRecords = new ArrayList<ImportItem>();
for (ImportItem itemRecord : projectRecords) {
for (String errorMessage : itemRecord.getErrors()) {
if (errorMessage.equals(overWriteErrorMessage)) {
overWriteRecords.add(itemRecord);
}
}
}
for (ImportItem overRecord : overWriteRecords) {
overRecord.getErrors().clear();
}
}
}
use of org.talend.repository.items.importexport.handlers.model.ImportItem in project tdi-studio-se by Talend.
the class ImportDemoProjectItemsPage method populateExistItemRecords.
private String populateExistItemRecords(final List<ResourcesManager> manager) {
//$NON-NLS-1$
String messageInfo = "";
final Collection<ImportItem> items = new ArrayList<ImportItem>();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
for (ResourcesManager rm : manager) {
items.addAll(importManager.populateImportingItems(rm, true, monitor));
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
};
try {
new ProgressMonitorDialog(getShell()).run(true, true, op);
} catch (Exception e) {
// ignore me
}
for (ImportItem itemRecord : items) {
if (itemRecord.getExistingItemWithSameId() != null && itemRecord.getExistingItemWithSameId() instanceof RepositoryViewObject) {
RepositoryViewObject reObject = (RepositoryViewObject) itemRecord.getExistingItemWithSameId();
if (itemRecord.getProperty() != null && reObject != null) {
if (!itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equalsIgnoreCase(reObject.getLabel())) {
messageInfo = Messages.getString("ImportDemoProjectPage.loseItems", reObject.getLabel());
}
if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel())) {
messageInfo = Messages.getString("ImportDemoProjectPage.overwriteItems");
}
}
}
}
return messageInfo;
}
Aggregations