Merge branch 'master' into feature_enable_push_in_deployment_view

This commit is contained in:
Gaurav
2016-08-09 13:15:24 +02:00
7 changed files with 41 additions and 24 deletions

View File

@@ -142,7 +142,7 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
protected void setContainerPropertValues(final Long tagId, final String tagName, final String tagColor) { protected void setContainerPropertValues(final Long tagId, final String tagName, final String tagColor) {
final TagData tagData = tagDetails.putIfAbsent(tagId, new TagData(tagId, tagName, tagColor)); final TagData tagData = tagDetails.putIfAbsent(tagId, new TagData(tagId, tagName, tagColor));
if(tagData == null){ if (tagData == null) {
final Item item = container.addItem(tagId); final Item item = container.addItem(tagId);
item.getItemProperty("id").setValue(tagId); item.getItemProperty("id").setValue(tagId);
updateItem(tagName, tagColor, item); updateItem(tagName, tagColor, item);
@@ -250,6 +250,7 @@ public abstract class AbstractTagToken<T extends BaseEntity> implements Serializ
protected void removeTokenItem(final Long tokenId, final String name) { protected void removeTokenItem(final Long tokenId, final String name) {
tokenField.removeToken(tokenId); tokenField.removeToken(tokenId);
tagDetails.remove(tokenId);
setContainerPropertValues(tokenId, name, tokensAdded.get(tokenId).getColor()); setContainerPropertValues(tokenId, name, tokensAdded.get(tokenId).getColor());
} }

View File

@@ -121,6 +121,7 @@ public class DistributionTagToken extends AbstractTagToken<DistributionSet> {
@Override @Override
protected void populateContainer() { protected void populateContainer() {
container.removeAllItems(); container.removeAllItems();
tagDetails.clear();
for (final DistributionSetTag tag : tagManagement.findAllDistributionSetTags()) { for (final DistributionSetTag tag : tagManagement.findAllDistributionSetTags()) {
setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()); setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour());
} }

View File

@@ -120,6 +120,7 @@ public class TargetTagToken extends AbstractTargetTagToken<Target> {
@Override @Override
protected void populateContainer() { protected void populateContainer() {
container.removeAllItems(); container.removeAllItems();
tagDetails.clear();
for (final TargetTag tag : tagManagement.findAllTargetTags()) { for (final TargetTag tag : tagManagement.findAllTargetTags()) {
setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()); setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour());
} }

View File

@@ -36,8 +36,6 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
@Override @Override
public void error(final ErrorEvent event) { public void error(final ErrorEvent event) {
LOG.error("Error in UI: ", event.getThrowable());
final Optional<Page> originError = getPageOriginError(event); final Optional<Page> originError = getPageOriginError(event);
if (originError.isPresent()) { if (originError.isPresent()) {
@@ -68,11 +66,15 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
return Optional.fromNullable(errorOrigin.getUI().getPage()); return Optional.fromNullable(errorOrigin.getUI().getPage());
} }
return Optional.absent(); return Optional.of(Page.getCurrent());
} }
protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) { protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) {
LOG.error("Error in UI: ", exception);
return createHawkbitErrorNotificationMessage(exception);
}
protected HawkbitErrorNotificationMessage createHawkbitErrorNotificationMessage(final Throwable exception) {
final I18N i18n = SpringContextHelper.getBean(I18N.class); final I18N i18n = SpringContextHelper.getBean(I18N.class);
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"), return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
i18n.get("message.error.temp", exception.getClass().getSimpleName()), false); i18n.get("message.error.temp", exception.getClass().getSimpleName()), false);

View File

@@ -43,7 +43,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventBus;
@@ -56,6 +55,7 @@ import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.ProgressBar; import com.vaadin.ui.ProgressBar;
import com.vaadin.ui.TextArea; import com.vaadin.ui.TextArea;
import com.vaadin.ui.UI;
import com.vaadin.ui.Upload; import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.FailedEvent; import com.vaadin.ui.Upload.FailedEvent;
import com.vaadin.ui.Upload.FailedListener; import com.vaadin.ui.Upload.FailedListener;
@@ -83,8 +83,6 @@ public class BulkUploadHandler extends CustomComponent
private final transient DeploymentManagement deploymentManagement; private final transient DeploymentManagement deploymentManagement;
private final transient DistributionSetManagement distributionSetManagement; private final transient DistributionSetManagement distributionSetManagement;
private final UINotification uINotification;
protected File tempFile = null; protected File tempFile = null;
private Upload upload; private Upload upload;
@@ -109,12 +107,11 @@ public class BulkUploadHandler extends CustomComponent
* @param targetManagement * @param targetManagement
* @param managementUIState * @param managementUIState
* @param deploymentManagement * @param deploymentManagement
* @param uINotification
* @param i18n * @param i18n
*/ */
public BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout, public BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout,
final TargetManagement targetManagement, final ManagementUIState managementUIState, final TargetManagement targetManagement, final ManagementUIState managementUIState,
final DeploymentManagement deploymentManagement, final UINotification uINotification, final I18N i18n) { final DeploymentManagement deploymentManagement, final I18N i18n) {
this.targetBulkUpdateWindowLayout = targetBulkUpdateWindowLayout; this.targetBulkUpdateWindowLayout = targetBulkUpdateWindowLayout;
this.comboBox = targetBulkUpdateWindowLayout.getDsNamecomboBox(); this.comboBox = targetBulkUpdateWindowLayout.getDsNamecomboBox();
this.descTextArea = targetBulkUpdateWindowLayout.getDescTextArea(); this.descTextArea = targetBulkUpdateWindowLayout.getDescTextArea();
@@ -122,7 +119,6 @@ public class BulkUploadHandler extends CustomComponent
this.progressBar = targetBulkUpdateWindowLayout.getProgressBar(); this.progressBar = targetBulkUpdateWindowLayout.getProgressBar();
this.managementUIState = managementUIState; this.managementUIState = managementUIState;
this.deploymentManagement = deploymentManagement; this.deploymentManagement = deploymentManagement;
this.uINotification = uINotification;
this.targetsCountLabel = targetBulkUpdateWindowLayout.getTargetsCountLabel(); this.targetsCountLabel = targetBulkUpdateWindowLayout.getTargetsCountLabel();
this.targetBulkTokenTags = targetBulkUpdateWindowLayout.getTargetBulkTokenTags(); this.targetBulkTokenTags = targetBulkUpdateWindowLayout.getTargetBulkTokenTags();
this.i18n = i18n; this.i18n = i18n;
@@ -178,6 +174,7 @@ public class BulkUploadHandler extends CustomComponent
} }
class UploadAsync implements Runnable { class UploadAsync implements Runnable {
final SucceededEvent event; final SucceededEvent event;
/** /**
@@ -193,7 +190,6 @@ public class BulkUploadHandler extends CustomComponent
if (tempFile == null) { if (tempFile == null) {
return; return;
} }
try (InputStream tempStream = new FileInputStream(tempFile)) { try (InputStream tempStream = new FileInputStream(tempFile)) {
readFileStream(tempStream); readFileStream(tempStream);
} catch (final FileNotFoundException e) { } catch (final FileNotFoundException e) {
@@ -201,12 +197,11 @@ public class BulkUploadHandler extends CustomComponent
} catch (final IOException e) { } catch (final IOException e) {
LOG.error("Error while opening temorary file ", e); LOG.error("Error while opening temorary file ", e);
} }
} }
private void readFileStream(final InputStream tempStream) { private void readFileStream(final InputStream tempStream) {
String line; String line;
try (BufferedReader reader = new BufferedReader( try (final BufferedReader reader = new BufferedReader(
new InputStreamReader(tempStream, Charset.defaultCharset()))) { new InputStreamReader(tempStream, Charset.defaultCharset()))) {
LOG.info("Bulk file upload started"); LOG.info("Bulk file upload started");
long innerCounter = 0; long innerCounter = 0;
@@ -218,21 +213,39 @@ public class BulkUploadHandler extends CustomComponent
* below event. * below event.
*/ */
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED)); eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
innerCounter++; innerCounter++;
readEachLine(line, innerCounter, totalFileSize); readEachLine(line, innerCounter, totalFileSize);
} }
doAssignments();
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED));
// Clearing after assignments are done
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().clear();
} catch (final IOException e) { } catch (final IOException e) {
LOG.error("Error reading file {}", tempFile.getName(), e); LOG.error("Error reading file {}", tempFile.getName(), e);
} catch (final RuntimeException e) {
if (UI.getCurrent() != null) {
UI.getCurrent().getErrorHandler().error(new com.vaadin.server.ErrorEvent(e));
}
} finally { } finally {
resetCounts();
deleteFile(); deleteFile();
} }
syncCountAfterUpload();
doAssignments();
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED));
// Clearing after assignments are done
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().clear();
resetCounts();
}
private void syncCountAfterUpload() {
if (managementUIState.getTargetTableFilters().getBulkUpload()
.getSucessfulUploadCount() != successfullTargetCount) {
managementUIState.getTargetTableFilters().getBulkUpload()
.setSucessfulUploadCount(successfullTargetCount);
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
}
if (managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount() != failedTargetCount) {
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(failedTargetCount);
}
} }
private double getTotalNumberOfLines() { private double getTotalNumberOfLines() {
@@ -457,4 +470,5 @@ public class BulkUploadHandler extends CustomComponent
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED)); eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED));
} }
} }
} }

View File

@@ -96,6 +96,7 @@ public class TargetBulkTokenTags extends AbstractTargetTagToken {
@Override @Override
protected void populateContainer() { protected void populateContainer() {
container.removeAllItems(); container.removeAllItems();
tagDetails.clear();
for (final TargetTag tag : tagManagement.findAllTargetTags()) { for (final TargetTag tag : tagManagement.findAllTargetTags()) {
setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()); setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour());
} }

View File

@@ -31,7 +31,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -73,9 +72,6 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
@Autowired @Autowired
private transient TargetManagement targetManagement; private transient TargetManagement targetManagement;
@Autowired
private transient UINotification uINotification;
@Autowired @Autowired
private transient EventBus.SessionEventBus eventBus; private transient EventBus.SessionEventBus eventBus;
@@ -178,7 +174,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
private BulkUploadHandler getBulkUploadHandler() { private BulkUploadHandler getBulkUploadHandler() {
final BulkUploadHandler bulkUploadHandler = new BulkUploadHandler(this, targetManagement, managementUIState, final BulkUploadHandler bulkUploadHandler = new BulkUploadHandler(this, targetManagement, managementUIState,
deploymentManagement, uINotification, i18n); deploymentManagement, i18n);
bulkUploadHandler.buildLayout(); bulkUploadHandler.buildLayout();
bulkUploadHandler.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_BUTTON); bulkUploadHandler.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_BUTTON);
return bulkUploadHandler; return bulkUploadHandler;
@@ -296,8 +292,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
descTextArea.clear(); descTextArea.clear();
targetBulkTokenTags.getTokenField().clear(); targetBulkTokenTags.getTokenField().clear();
targetBulkTokenTags.populateContainer(); targetBulkTokenTags.populateContainer();
progressBar.setValue(0f); progressBar.setValue(0F);
progressBar.setVisible(false); progressBar.setVisible(false);
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(0F);
targetsCountLabel.setVisible(false); targetsCountLabel.setVisible(false);
} }