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) {
final TagData tagData = tagDetails.putIfAbsent(tagId, new TagData(tagId, tagName, tagColor));
if(tagData == null){
if (tagData == null) {
final Item item = container.addItem(tagId);
item.getItemProperty("id").setValue(tagId);
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) {
tokenField.removeToken(tokenId);
tagDetails.remove(tokenId);
setContainerPropertValues(tokenId, name, tokensAdded.get(tokenId).getColor());
}

View File

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

View File

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

View File

@@ -36,8 +36,6 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
@Override
public void error(final ErrorEvent event) {
LOG.error("Error in UI: ", event.getThrowable());
final Optional<Page> originError = getPageOriginError(event);
if (originError.isPresent()) {
@@ -68,11 +66,15 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
return Optional.fromNullable(errorOrigin.getUI().getPage());
}
return Optional.absent();
return Optional.of(Page.getCurrent());
}
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);
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
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.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.spring.events.EventBus;
@@ -56,6 +55,7 @@ import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.ProgressBar;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.UI;
import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.FailedEvent;
import com.vaadin.ui.Upload.FailedListener;
@@ -83,8 +83,6 @@ public class BulkUploadHandler extends CustomComponent
private final transient DeploymentManagement deploymentManagement;
private final transient DistributionSetManagement distributionSetManagement;
private final UINotification uINotification;
protected File tempFile = null;
private Upload upload;
@@ -109,12 +107,11 @@ public class BulkUploadHandler extends CustomComponent
* @param targetManagement
* @param managementUIState
* @param deploymentManagement
* @param uINotification
* @param i18n
*/
public BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout,
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.comboBox = targetBulkUpdateWindowLayout.getDsNamecomboBox();
this.descTextArea = targetBulkUpdateWindowLayout.getDescTextArea();
@@ -122,7 +119,6 @@ public class BulkUploadHandler extends CustomComponent
this.progressBar = targetBulkUpdateWindowLayout.getProgressBar();
this.managementUIState = managementUIState;
this.deploymentManagement = deploymentManagement;
this.uINotification = uINotification;
this.targetsCountLabel = targetBulkUpdateWindowLayout.getTargetsCountLabel();
this.targetBulkTokenTags = targetBulkUpdateWindowLayout.getTargetBulkTokenTags();
this.i18n = i18n;
@@ -178,6 +174,7 @@ public class BulkUploadHandler extends CustomComponent
}
class UploadAsync implements Runnable {
final SucceededEvent event;
/**
@@ -193,7 +190,6 @@ public class BulkUploadHandler extends CustomComponent
if (tempFile == null) {
return;
}
try (InputStream tempStream = new FileInputStream(tempFile)) {
readFileStream(tempStream);
} catch (final FileNotFoundException e) {
@@ -201,12 +197,11 @@ public class BulkUploadHandler extends CustomComponent
} catch (final IOException e) {
LOG.error("Error while opening temorary file ", e);
}
}
private void readFileStream(final InputStream tempStream) {
String line;
try (BufferedReader reader = new BufferedReader(
try (final BufferedReader reader = new BufferedReader(
new InputStreamReader(tempStream, Charset.defaultCharset()))) {
LOG.info("Bulk file upload started");
long innerCounter = 0;
@@ -218,21 +213,39 @@ public class BulkUploadHandler extends CustomComponent
* below event.
*/
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
while ((line = reader.readLine()) != null) {
innerCounter++;
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) {
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 {
resetCounts();
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() {
@@ -457,4 +470,5 @@ public class BulkUploadHandler extends CustomComponent
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED));
}
}
}

View File

@@ -96,6 +96,7 @@ public class TargetBulkTokenTags extends AbstractTargetTagToken {
@Override
protected void populateContainer() {
container.removeAllItems();
tagDetails.clear();
for (final TargetTag tag : tagManagement.findAllTargetTags()) {
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.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -73,9 +72,6 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
@Autowired
private transient TargetManagement targetManagement;
@Autowired
private transient UINotification uINotification;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@@ -178,7 +174,7 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
private BulkUploadHandler getBulkUploadHandler() {
final BulkUploadHandler bulkUploadHandler = new BulkUploadHandler(this, targetManagement, managementUIState,
deploymentManagement, uINotification, i18n);
deploymentManagement, i18n);
bulkUploadHandler.buildLayout();
bulkUploadHandler.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_BUTTON);
return bulkUploadHandler;
@@ -296,8 +292,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
descTextArea.clear();
targetBulkTokenTags.getTokenField().clear();
targetBulkTokenTags.populateContainer();
progressBar.setValue(0f);
progressBar.setValue(0F);
progressBar.setVisible(false);
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(0F);
targetsCountLabel.setVisible(false);
}