List of usage examples for com.vaadin.server VaadinService getCurrentRequest
public static VaadinRequest getCurrentRequest()
From source file:org.ikasan.dashboard.ui.mappingconfiguration.action.DeleteMappingConfigurationAction.java
License:BSD License
@Override public void exectuteAction() { try {/*from w w w . ja va 2 s.c om*/ MappingConfiguration mappingConfiguration = this.mappingConfigurationService .getMappingConfigurationById(this.mappingConfigurationId); this.mappingConfigurationService.deleteMappingConfiguration(mappingConfiguration); this.searchResultsTable.removeItem(this.mappingConfigurationId); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Deleted mapping configuration: [Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]", authentication.getName()); logger.info("User: " + authentication.getName() + " successfully deleted the following Mapping Configuration: " + mappingConfiguration); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Cauget exception trying to remove a Mapping Configuration!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.action.DeleteRowAction.java
License:BSD License
@Override public void exectuteAction() { IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); StringBuilder sb = new StringBuilder("Deleted mapping configuration value(s): [Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]"); for (SourceConfigurationValue sourceConfigurationValue : this.sourceConfigurationValues) { sb.append(" [Src Value=" + sourceConfigurationValue.getSourceSystemValue() + "] [Tgt Value=" + sourceConfigurationValue.getTargetConfigurationValue().getTargetSystemValue() + "]"); }//from w w w . j ava 2 s . c o m logger.info("User: " + authentication.getName() + " attempting to delete: " + this.sourceConfigurationValues.size() + " configuration values."); this.mappingConfiguration.getSourceConfigurationValues().removeAll(this.sourceConfigurationValues); try { this.mappingConfigurationConfigurationValuesTable.save(); this.mappingConfigurationService.saveMappingConfiguration(this.mappingConfiguration); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, sb.toString(), authentication.getName()); logger.info("User: " + authentication.getName() + " successfully deleted the following configuration values: " + this.sourceConfigurationValues); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Cauget exception trying to remove a Mapping Configuration value!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } for (SourceConfigurationValue value : sourceConfigurationValues) { this.mappingConfigurationConfigurationValuesTable.removeItem(value); } }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.component.MappingConfigurationConfigurationValuesTable.java
License:BSD License
/** * Method to save values associated with the component. * /* w w w . j a v a 2 s .c om*/ * @throws Exception */ public void save() throws Exception { for (SourceConfigurationValue value : this.mappingConfiguration.getSourceConfigurationValues()) { Long numberOfSourceConfigurationValues = this.mappingConfigurationService .getNumberOfSourceConfigurationValuesReferencingTargetConfigurationValue( value.getTargetConfigurationValue()); if (numberOfSourceConfigurationValues == 0) { this.mappingConfigurationService .deleteTargetConfigurationValue(value.getTargetConfigurationValue()); } else { IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); logger.info("User: " + authentication.getName() + " saving Target Configuration Value: " + value); this.mappingConfigurationService.saveTargetConfigurationValue(value.getTargetConfigurationValue()); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Saving Target Configuration Value: " + value, authentication.getName()); } } }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.component.MappingConfigurationConfigurationValuesTable.java
License:BSD License
/** * Method to add a record to the component. * //from ww w. j a va 2 s . c o m * @throws MappingConfigurationServiceException */ public void addNewRecord() throws MappingConfigurationServiceException { Long sourceSystemGroupId = null; if (this.mappingConfiguration.getNumberOfParams() > 1) { sourceSystemGroupId = this.mappingConfigurationService.getNextSequenceNumber(); } TargetConfigurationValue targetConfigurationValue = new TargetConfigurationValue(); targetConfigurationValue.setTargetSystemValue("Add targetSystemValue"); this.mappingConfigurationService.saveTargetConfigurationValue(targetConfigurationValue); VerticalLayout tableCellLayout = new VerticalLayout(); SourceConfigurationValue sourceConfigurationValue = null; final Button deleteButton = new Button("Delete"); ArrayList<SourceConfigurationValue> sourceConfigurationValues = new ArrayList<SourceConfigurationValue>(); for (int i = 0; i < this.mappingConfiguration.getNumberOfParams(); i++) { sourceConfigurationValue = new SourceConfigurationValue(); sourceConfigurationValue.setSourceSystemValue("Add source system value"); sourceConfigurationValue.setSourceConfigGroupId(sourceSystemGroupId); sourceConfigurationValue.setTargetConfigurationValue(targetConfigurationValue); sourceConfigurationValue.setMappingConfigurationId(this.mappingConfiguration.getId()); sourceConfigurationValues.add(sourceConfigurationValue); this.mappingConfiguration.getSourceConfigurationValues().add(sourceConfigurationValue); BeanItem<SourceConfigurationValue> item = new BeanItem<SourceConfigurationValue>( sourceConfigurationValue); final TextField tf = new TextField(item.getItemProperty("sourceSystemValue")); tableCellLayout.addComponent(tf); tf.setReadOnly(true); tf.setWidth(300, Unit.PIXELS); } BeanItem<TargetConfigurationValue> targetConfigurationItem = new BeanItem<TargetConfigurationValue>( targetConfigurationValue); final TextField targetConfigurationTextField = new TextField( targetConfigurationItem.getItemProperty("targetSystemValue")); targetConfigurationTextField.setReadOnly(true); targetConfigurationTextField.setWidth(300, Unit.PIXELS); final DeleteRowAction action = new DeleteRowAction(sourceConfigurationValues, this.mappingConfiguration, this, this.mappingConfigurationService, this.systemEventService); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.setDescription("Delete this record"); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { IkasanMessageDialog dialog = new IkasanMessageDialog("Delete record", "This mapping configuration record will be permanently removed. " + "Are you sure you wish to proceed?.", action); UI.getCurrent().addWindow(dialog); } }); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.EDIT_MAPPING_AUTHORITY)) || authentication.canAccessLinkedItem(PolicyLinkTypeConstants.MAPPING_CONFIGURATION_LINK_TYPE, mappingConfiguration.getId())) { deleteButton.setVisible(true); } else { deleteButton.setVisible(false); } Item item = this.container.addItemAt(0, sourceConfigurationValue); Property<Layout> sourceProperty = item.getItemProperty("Source Configuration Value"); sourceProperty.setValue(tableCellLayout); Property<TextField> targetProperty = item.getItemProperty("Target Configuration Value"); targetProperty.setValue(targetConfigurationTextField); Property<Button> deleteProperty = item.getItemProperty("Delete"); deleteProperty.setValue(deleteButton); this.mappingConfigurationService.saveMappingConfiguration(mappingConfiguration); this.setEditable(true); IkasanAuthentication principal = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); logger.info("User: " + principal.getName() + " added new mapping configuration value for Mapping Configuration " + this.mappingConfiguration); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Added new mapping configuration value for Mapping Configuration: " + this.mappingConfiguration, principal.getName()); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.component.MappingConfigurationConfigurationValuesTable.java
License:BSD License
/** * Method to help populate the table with values associated with the MappingConfiguration. * //w w w. j a v a 2 s . co m * @param mappingConfiguration */ public void populateTable(final MappingConfiguration mappingConfiguration) { this.mappingConfiguration = mappingConfiguration; Set<SourceConfigurationValue> sourceConfigurationValues = mappingConfiguration .getSourceConfigurationValues(); super.removeAllItems(); Iterator<SourceConfigurationValue> sourceConfigurationValueItr = sourceConfigurationValues.iterator(); ArrayList<SourceConfigurationValue> usedSourceConfigurationValues = new ArrayList<SourceConfigurationValue>(); ArrayList<SourceConfigurationValue> groupedSourceSystemValues = new ArrayList<SourceConfigurationValue>(); while (sourceConfigurationValueItr.hasNext()) { SourceConfigurationValue value = sourceConfigurationValueItr.next(); VerticalLayout tableCellLayout = new VerticalLayout(); for (int i = 0; i < this.mappingConfiguration.getNumberOfParams(); i++) { if (!usedSourceConfigurationValues.contains(value)) { groupedSourceSystemValues.add(value); BeanItem<SourceConfigurationValue> item = new BeanItem<SourceConfigurationValue>(value); final TextField tf = new TextField(item.getItemProperty("sourceSystemValue")); tf.setWidth(300, Unit.PIXELS); tableCellLayout.addComponent(tf); tf.setReadOnly(true); usedSourceConfigurationValues.add(value); Iterator<SourceConfigurationValue> partnerSourceConfigurationValueItr = sourceConfigurationValues .iterator(); while (partnerSourceConfigurationValueItr.hasNext()) { SourceConfigurationValue partnerSourceConfigurationValue = partnerSourceConfigurationValueItr .next(); if (partnerSourceConfigurationValue.getSourceConfigGroupId() != null && !usedSourceConfigurationValues.contains(partnerSourceConfigurationValue) && partnerSourceConfigurationValue.getId().compareTo(value.getId()) != 0 && partnerSourceConfigurationValue.getSourceConfigGroupId() .compareTo(value.getSourceConfigGroupId()) == 0) { groupedSourceSystemValues.add(partnerSourceConfigurationValue); item = new BeanItem<SourceConfigurationValue>(partnerSourceConfigurationValue); final TextField stf = new TextField(item.getItemProperty("sourceSystemValue")); stf.setWidth(300, Unit.PIXELS); tableCellLayout.addComponent(stf); stf.setReadOnly(true); usedSourceConfigurationValues.add(partnerSourceConfigurationValue); } } TargetConfigurationValue targetConfigurationValue = value.getTargetConfigurationValue(); BeanItem<TargetConfigurationValue> targetConfigurationItem = new BeanItem<TargetConfigurationValue>( targetConfigurationValue); final TextField targetConfigurationTextField = new TextField( targetConfigurationItem.getItemProperty("targetSystemValue")); targetConfigurationTextField.setReadOnly(true); targetConfigurationTextField.setWidth(300, Unit.PIXELS); final DeleteRowAction action = new DeleteRowAction(groupedSourceSystemValues, this.mappingConfiguration, this, this.mappingConfigurationService, this.systemEventService); final Button deleteButton = new Button("Delete"); deleteButton.setData(value); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.setDescription("Delete this record"); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { IkasanMessageDialog dialog = new IkasanMessageDialog("Delete record", "This mapping configuration record will be permanently removed. " + "Are you sure you wish to proceed?.", action); UI.getCurrent().addWindow(dialog); } }); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService .getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.EDIT_MAPPING_AUTHORITY)) || authentication.canAccessLinkedItem( PolicyLinkTypeConstants.MAPPING_CONFIGURATION_LINK_TYPE, mappingConfiguration.getId())) { deleteButton.setVisible(true); } else { deleteButton.setVisible(false); } this.addItem(new Object[] { tableCellLayout, targetConfigurationTextField, deleteButton }, value); groupedSourceSystemValues = new ArrayList<SourceConfigurationValue>(); } } } }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.component.MappingConfigurationConfigurationValuesTable.java
License:BSD License
@Override public boolean removeAllItems() { for (SourceConfigurationValue value : this.mappingConfiguration.getSourceConfigurationValues()) { this.mappingConfigurationService.deleteSourceConfigurationValue(value); Long numberOfSourceConfigurationValues = this.mappingConfigurationService .getNumberOfSourceConfigurationValuesReferencingTargetConfigurationValue( value.getTargetConfigurationValue()); if (numberOfSourceConfigurationValues == 0) { this.mappingConfigurationService .deleteTargetConfigurationValue(value.getTargetConfigurationValue()); }/*from w ww . j a va2 s . c o m*/ } IkasanAuthentication principal = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); logger.info("User: " + principal.getName() + " deleted all records for Mapping Configuration " + this.mappingConfiguration); String message = "[Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "] [Description=" + mappingConfiguration.getDescription() + "] [Number of source params=" + mappingConfiguration.getNumberOfParams() + "]"; systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Deleted all configuration values for Mapping Configuration " + message, principal.getName()); return super.removeAllItems(); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.data.NewClientFieldGroup.java
License:BSD License
@Override public void commit() throws CommitException { Field<String> name = (Field<String>) this.getField(NAME); Field<String> keyLocationQueryProcessorType = (Field<String>) this .getField(KEY_LOCATION_QUERY_PROCESSOR_TYPE); ConfigurationServiceClient client = new ConfigurationServiceClient(); client.setKeyLocationQueryProcessorType(keyLocationQueryProcessorType.getValue()); client.setName(name.getValue());/*from w w w .ja v a 2 s. co m*/ try { this.mappingConfigurationService.saveConfigurationServiceClient(client); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Created new mapping configuration client: " + client.getName(), authentication.getName()); logger.info( "User: " + authentication.getName() + " added a new Mapping Configuration Client: " + client); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Cauget exception trying to save a new Client!", sw.toString(), Notification.Type.ERROR_MESSAGE); } this.refreshGroup.refresh(); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.data.NewConfigurationTypeFieldGroup.java
License:BSD License
@Override public void commit() throws CommitException { Field<String> name = (Field<String>) this.getField(NAME); ConfigurationType type = new ConfigurationType(); type.setName(name.getValue());//from w w w .j a va 2s. c om try { this.mappingConfigurationService.saveConfigurationType(type); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Created new mapping configuration type: " + type.getName(), authentication.getName()); logger.info("User: " + authentication.getName() + " added a new Mapping Configuration Type: " + type); } catch (Exception e) { throw new CommitException(e); } this.refreshGroup.refresh(); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.data.NewContextFieldGroup.java
License:BSD License
@Override public void commit() throws CommitException { Field<String> name = (Field<String>) this.getField(NAME); Field<String> description = (Field<String>) this.getField(DESCRIPTION); ConfigurationContext context = new ConfigurationContext(); context.setDescription(description.getValue()); context.setName(name.getValue());/*from ww w . j a v a 2 s .co m*/ try { this.mappingConfigurationService.saveConfigurationConext(context); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Created new mapping configuration context: " + context.getName(), authentication.getName()); logger.info("User: " + authentication.getName() + " added a new Mapping Configuration Context: " + context); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Cauget exception trying to save a new Configuration Context!", sw.toString(), Notification.Type.ERROR_MESSAGE); } this.refreshGroup.refresh(); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationPanel.java
License:BSD License
/** * Helper method to save values associated with this panel. * // w ww. j a v a 2s. co m * @throws InvalidValueException * @throws Exception */ public void save() throws InvalidValueException, Exception { IkasanAuthentication principal = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); try { try { this.clientComboBox.validate(); this.typeComboBox.validate(); this.sourceContextComboBox.validate(); this.targetContextComboBox.validate(); this.descriptionTextArea.validate(); this.numberOfParametersTextField.validate(); for (TextField tf : this.parameterQueryTextFields) { tf.validate(); } } catch (InvalidValueException e) { this.clientComboBox.setValidationVisible(true); this.typeComboBox.setValidationVisible(true); this.sourceContextComboBox.setValidationVisible(true); this.targetContextComboBox.setValidationVisible(true); this.descriptionTextArea.setValidationVisible(true); this.numberOfParametersTextField.setValidationVisible(true); for (TextField tf : this.parameterQueryTextFields) { tf.setValidationVisible(true); } throw e; } logger.info("this.parameterQueryTextFields.size() = " + this.parameterQueryTextFields.size()); logger.info("this.mappingConfiguration.getNumberOfParams() = " + this.mappingConfiguration.getNumberOfParams()); if (this.parameterQueryTextFields.size() != this.mappingConfiguration.getNumberOfParams()) { throw new Exception("You must define the key location queries!"); } logger.info("Attempting to save mapping configuration."); this.mappingConfiguration .setConfigurationServiceClient((ConfigurationServiceClient) this.clientComboBox.getValue()); this.mappingConfiguration.setConfigurationType((ConfigurationType) this.typeComboBox.getValue()); logger.info("Source context = ." + ((ConfigurationContext) this.sourceContextComboBox.getValue()).getName()); this.mappingConfiguration .setSourceContext((ConfigurationContext) this.sourceContextComboBox.getValue()); this.mappingConfiguration .setTargetContext((ConfigurationContext) this.targetContextComboBox.getValue()); try { logger.info("User: " + principal.getName() + " saving Mapping Configuration: " + this.mappingConfiguration); this.mappingConfigurationService.saveMappingConfiguration(this.mappingConfiguration); String message = "[Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "] [Description=" + mappingConfiguration.getDescription() + "] [Number of source params=" + mappingConfiguration.getNumberOfParams() + "]"; systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Saving Mapping Configuration: " + message, principal.getName()); } catch (MappingConfigurationServiceException e) { e.printStackTrace(); throw new Exception("Unable to save Mapping Configuration. Client, " + "Type, Source and Target Context must be unique!"); } for (KeyLocationQuery query : this.keyLocationQueries) { query.setMappingConfigurationId(this.mappingConfiguration.getId()); logger.info("User: " + principal.getName() + " saving Key Location Query: " + query); this.mappingConfigurationService.saveKeyLocationQuery(query); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Saving Key Location Query: " + query, principal.getName()); } this.mappingConfigurationConfigurationValuesTable.save(); this.clientComboBox.setValidationVisible(false); this.typeComboBox.setValidationVisible(false); this.sourceContextComboBox.setValidationVisible(false); this.targetContextComboBox.setValidationVisible(false); this.descriptionTextArea.setValidationVisible(false); this.numberOfParametersTextField.setValidationVisible(false); } catch (InvalidValueException e) { throw e; } catch (Exception e) { throw e; } }