Example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

List of usage examples for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

Introduction

In this page you can find the example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList.

Prototype

public CopyOnWriteArrayList(E[] toCopyIn) 

Source Link

Document

Creates a list holding a copy of the given array.

Usage

From source file:org.apache.accumulo.tserver.tablet.Tablet.java

public Tablet(final TabletServer tabletServer, final KeyExtent extent, final TabletResourceManager trm,
        TabletData data) throws IOException {

    this.tabletServer = tabletServer;
    this.extent = extent;
    this.tabletResources = trm;
    this.lastLocation = data.getLastLocation();
    this.lastFlushID = data.getFlushID();
    this.lastCompactID = data.getCompactID();
    this.splitCreationTime = data.getSplitTime();
    this.tabletTime = TabletTime.getInstance(data.getTime());
    this.persistedTime = tabletTime.getTime();
    this.logId = tabletServer.createLogId(extent);

    TableConfiguration tblConf = tabletServer.getTableConfiguration(extent);
    if (null == tblConf) {
        Tables.clearCache(tabletServer.getInstance());
        tblConf = tabletServer.getTableConfiguration(extent);
        requireNonNull(tblConf, "Could not get table configuration for " + extent.getTableId());
    }/* w ww.j  a  v  a 2 s  .c  o m*/

    this.tableConfiguration = tblConf;

    // translate any volume changes
    VolumeManager fs = tabletServer.getFileSystem();
    boolean replicationEnabled = ReplicationConfigurationUtil.isEnabled(extent, this.tableConfiguration);
    TabletFiles tabletPaths = new TabletFiles(data.getDirectory(), data.getLogEntris(), data.getDataFiles());
    tabletPaths = VolumeUtil.updateTabletVolumes(tabletServer, tabletServer.getLock(), fs, extent, tabletPaths,
            replicationEnabled);

    // deal with relative path for the directory
    Path locationPath;
    if (tabletPaths.dir.contains(":")) {
        locationPath = new Path(tabletPaths.dir);
    } else {
        locationPath = tabletServer.getFileSystem().getFullPath(FileType.TABLE,
                extent.getTableId() + tabletPaths.dir);
    }
    this.location = locationPath;
    this.tabletDirectory = tabletPaths.dir;
    for (Entry<Long, List<FileRef>> entry : data.getBulkImported().entrySet()) {
        this.bulkImported.put(entry.getKey(), new CopyOnWriteArrayList<FileRef>(entry.getValue()));
    }
    setupDefaultSecurityLabels(extent);

    final List<LogEntry> logEntries = tabletPaths.logEntries;
    final SortedMap<FileRef, DataFileValue> datafiles = tabletPaths.datafiles;

    tableConfiguration.addObserver(configObserver = new ConfigurationObserver() {

        private void reloadConstraints() {
            log.debug("Reloading constraints for extent: " + extent);
            constraintChecker.set(new ConstraintChecker(tableConfiguration));
        }

        @Override
        public void propertiesChanged() {
            reloadConstraints();

            try {
                setupDefaultSecurityLabels(extent);
            } catch (Exception e) {
                log.error("Failed to reload default security labels for extent: " + extent.toString());
            }
        }

        @Override
        public void propertyChanged(String prop) {
            if (prop.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey()))
                reloadConstraints();
            else if (prop.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey())) {
                try {
                    log.info("Default security labels changed for extent: " + extent.toString());
                    setupDefaultSecurityLabels(extent);
                } catch (Exception e) {
                    log.error("Failed to reload default security labels for extent: " + extent.toString());
                }
            }

        }

        @Override
        public void sessionExpired() {
            log.debug("Session expired, no longer updating per table props...");
        }

    });

    tableConfiguration.getNamespaceConfiguration().addObserver(configObserver);
    tabletMemory = new TabletMemory(this);

    // Force a load of any per-table properties
    configObserver.propertiesChanged();
    if (!logEntries.isEmpty()) {
        log.info("Starting Write-Ahead Log recovery for " + this.extent);
        final AtomicLong entriesUsedOnTablet = new AtomicLong(0);
        // track max time from walog entries without timestamps
        final AtomicLong maxTime = new AtomicLong(Long.MIN_VALUE);
        final CommitSession commitSession = getTabletMemory().getCommitSession();
        try {
            Set<String> absPaths = new HashSet<String>();
            for (FileRef ref : datafiles.keySet())
                absPaths.add(ref.path().toString());

            tabletServer.recover(this.getTabletServer().getFileSystem(), extent, tableConfiguration, logEntries,
                    absPaths, new MutationReceiver() {
                        @Override
                        public void receive(Mutation m) {
                            // LogReader.printMutation(m);
                            Collection<ColumnUpdate> muts = m.getUpdates();
                            for (ColumnUpdate columnUpdate : muts) {
                                if (!columnUpdate.hasTimestamp()) {
                                    // if it is not a user set timestamp, it must have been set
                                    // by the system
                                    maxTime.set(Math.max(maxTime.get(), columnUpdate.getTimestamp()));
                                }
                            }
                            getTabletMemory().mutate(commitSession, Collections.singletonList(m));
                            entriesUsedOnTablet.incrementAndGet();
                        }
                    });

            if (maxTime.get() != Long.MIN_VALUE) {
                tabletTime.useMaxTimeFromWALog(maxTime.get());
            }
            commitSession.updateMaxCommittedTime(tabletTime.getTime());

            if (entriesUsedOnTablet.get() == 0) {
                log.debug("No replayed mutations applied, removing unused entries for " + extent);
                MetadataTableUtil.removeUnusedWALEntries(getTabletServer(), extent, logEntries,
                        tabletServer.getLock());

                // No replication update to be made because the fact that this tablet didn't use any mutations
                // from the WAL implies nothing about use of this WAL by other tablets. Do nothing.

                logEntries.clear();
            } else if (ReplicationConfigurationUtil.isEnabled(extent,
                    tabletServer.getTableConfiguration(extent))) {
                // The logs are about to be re-used by this tablet, we need to record that they have data for this extent,
                // but that they may get more data. logEntries is not cleared which will cause the elements
                // in logEntries to be added to the currentLogs for this Tablet below.
                //
                // This update serves the same purpose as an update during a MinC. We know that the WAL was defined
                // (written when the WAL was opened) but this lets us know there are mutations written to this WAL
                // that could potentially be replicated. Because the Tablet is using this WAL, we can be sure that
                // the WAL isn't closed (WRT replication Status) and thus we're safe to update its progress.
                Status status = StatusUtil.openWithUnknownLength();
                for (LogEntry logEntry : logEntries) {
                    log.debug("Writing updated status to metadata table for " + logEntry.filename + " "
                            + ProtobufUtil.toString(status));
                    ReplicationTableUtil.updateFiles(tabletServer, extent, logEntry.filename, status);
                }
            }

        } catch (Throwable t) {
            if (tableConfiguration.getBoolean(Property.TABLE_FAILURES_IGNORE)) {
                log.warn("Error recovering from log files: ", t);
            } else {
                throw new RuntimeException(t);
            }
        }
        // make some closed references that represent the recovered logs
        currentLogs = new ConcurrentSkipListSet<DfsLogger>();
        for (LogEntry logEntry : logEntries) {
            currentLogs.add(new DfsLogger(tabletServer.getServerConfig(), logEntry.filename,
                    logEntry.getColumnQualifier().toString()));
        }

        log.info("Write-Ahead Log recovery complete for " + this.extent + " (" + entriesUsedOnTablet.get()
                + " mutations applied, " + getTabletMemory().getNumEntries() + " entries created)");
    }

    String contextName = tableConfiguration.get(Property.TABLE_CLASSPATH);
    if (contextName != null && !contextName.equals("")) {
        // initialize context classloader, instead of possibly waiting for it to initialize for a scan
        // TODO this could hang, causing other tablets to fail to load - ACCUMULO-1292
        AccumuloVFSClassLoader.getContextManager().getClassLoader(contextName);
    }

    // do this last after tablet is completely setup because it
    // could cause major compaction to start
    datafileManager = new DatafileManager(this, datafiles);

    computeNumEntries();

    getDatafileManager().removeFilesAfterScan(data.getScanFiles());

    // look for hints of a failure on the previous tablet server
    if (!logEntries.isEmpty() || needsMajorCompaction(MajorCompactionReason.NORMAL)) {
        // look for any temp files hanging around
        removeOldTemporaryFiles();
    }

    log.log(TLevel.TABLET_HIST, extent + " opened");
}

From source file:io.github.jeddict.reveng.klass.RevEngWizardDescriptor.java

private int loadJavaClasses(final ProgressReporter reporter, int progressIndex,
        final List<ClassExplorer> selectedClasses, final EntityMappings entityMappings) {

    List<ClassExplorer> classes = new CopyOnWriteArrayList<>(selectedClasses);

    for (ClassExplorer clazz : classes) {
        if (clazz.isEntity() || clazz.isMappedSuperclass()) {
            String progressMsg = getMessage(RevEngWizardDescriptor.class, "MSG_Progress_JPA_Class_Parsing",
                    clazz.getName() + JAVA_EXT_SUFFIX);//NOI18N
            reporter.progress(progressMsg, progressIndex++);
            parseJavaClass(entityMappings, clazz);
        }// w  w  w. j  a v a  2 s  . co  m
    }
    for (ClassExplorer clazz : classes) {
        if (!clazz.isEntity() && !clazz.isMappedSuperclass()) {
            String progressMsg = getMessage(RevEngWizardDescriptor.class, "MSG_Progress_JPA_Class_Parsing",
                    clazz.getName() + JAVA_EXT_SUFFIX);//NOI18N
            reporter.progress(progressMsg, progressIndex++);
            parseJavaClass(entityMappings, clazz);
        }
    }
    return progressIndex;
}

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.MessagesActivity.java

private void doRefresh(final boolean keepCurrentPos, final int inc, final boolean newMsgs) {
    new AsyncTask<Void, Void, List<MessageObject>>() {
        @Override//from   ww  w .  j  a va2s  .  c o m
        protected List<MessageObject> doInBackground(Void... params) {
            // First we need to know if the timeline has a new id to know if
            // this actual timeline is not a local anymore
            ArrayList<TimelineObject> list = DataBasesAccess.getInstance(getApplicationContext())
                    .TimelinesDataBaseRead();
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).getParty().getId().equals(timeline.getParty().getId())) {
                    timeline.setId(list.get(i).getId());
                    break;
                }
            }

            List<MessageObject> auxList;
            if (timeline.getId() == ConstantKeys.LONG_DEFAULT) {
                auxList = DataBasesAccess.getInstance(getApplicationContext())
                        .MessagesDataBaseReadSelected(null, timeline.getParty().getId());
            } else {
                auxList = DataBasesAccess.getInstance(getApplicationContext())
                        .MessagesDataBaseReadSelected(timeline.getId(), null);
            }

            setupMessagesToBeShown(auxList);

            return auxList;
        }

        @Override
        protected void onPostExecute(List<MessageObject> list) {
            if (newMsgs && listView.getLastVisiblePosition() < list.size() - 1) {
                updateBottom.setVisibility(View.VISIBLE);
            }

            messageList = new CopyOnWriteArrayList<MessageObject>(list);
            updateListView(keepCurrentPos, inc, true);
        }
    }.execute();
}

From source file:webserver.WebResource.java

@Path("index/settings.html")
@GET/*w  w  w. j a va  2s.c o m*/
public Response doProfileSettings() {

    try {

        PebbleHelper pebbleHelper = PebbleHelper.getPebbleHelper("web/settings.html", request);

        if (ServletUtils.isRemoteRequest(request)) {
            return error404(request, "This page is disabled for remote usage");
        }

        String profileName = request.getParameter("profilename");

        List<Name> namesAsList = new CopyOnWriteArrayList<Name>(Controller.getInstance().getNamesAsList());

        for (Name name : namesAsList) {
            if (!Profile.isAllowedProfileName(name.getName())) {
                namesAsList.remove(name);
            }
        }

        pebbleHelper.getContextMap().put("names", namesAsList);

        handleSelectNameAndProfile(pebbleHelper, profileName, namesAsList);

        return Response.ok(pebbleHelper.evaluate(), "text/html; charset=utf-8").build();
    } catch (Throwable e) {
        LOGGER.error(e.getMessage(), e);
        return error404(request, null);
    }

}

From source file:io.github.jeddict.jpa.modeler.properties.named.nativequery.NamedNativeQueryPanel.java

private NAttributeEntity getQueryHint() {
    final NAttributeEntity attributeEntityObj = new NAttributeEntity("QueryHint", "Query Hint", "");
    attributeEntityObj.setCountDisplay(new String[] { "No QueryHints", "One QueryHint", " QueryHints" });
    List<Column> columns = new ArrayList<>();
    columns.add(new Column("Name", false, String.class));
    columns.add(new Column("Value", false, String.class));
    attributeEntityObj.setColumns(columns);
    attributeEntityObj.setCustomDialog(new QueryHintPanel());
    attributeEntityObj.setTableDataListener(new INEntityDataListener() {
        List<Object[]> data = new LinkedList<>();
        int count;

        @Override//from   w  ww  .  j  a va  2  s. c om
        public void initCount() {
            if (namedNativeQuery != null && namedNativeQuery.getHint() != null) {
                count = namedNativeQuery.getHint().size();
            } else {
                count = 0;
            }
        }

        @Override
        public int getCount() {
            return count;
        }

        @Override
        public void initData() {
            List<Object[]> data_local = new LinkedList<>();
            if (namedNativeQuery != null && namedNativeQuery.getHint() != null) {
                for (QueryHint queryHint : new CopyOnWriteArrayList<>(namedNativeQuery.getHint())) {
                    Object[] row = new Object[5];
                    row[0] = queryHint;
                    row[1] = queryHint.getName();
                    row[2] = queryHint.getValue();
                    data_local.add(row);
                }
            }
            this.data = data_local;
        }

        @Override
        public List<Object[]> getData() {
            return data;
        }

        @Override
        public void setData(List<Object[]> data) {
            if (namedNativeQuery != null && namedNativeQuery.getHint() != null) {
                namedNativeQuery.getHint().clear();
            }
            for (Object[] row : data) {
                QueryHint queryHint = (QueryHint) row[0];
                namedNativeQuery.getHint().add(queryHint);
            }
            initData();
        }
    });
    return attributeEntityObj;
}

From source file:org.apache.ambari.server.state.cluster.ClusterImpl.java

@Override
public List<ServiceComponentHost> getServiceComponentHosts(String hostname) {
    loadServiceHostComponents();//from ww w . j a  v a2 s  .c  om
    clusterGlobalLock.readLock().lock();
    try {
        if (serviceComponentHostsByHost.containsKey(hostname)) {
            return new CopyOnWriteArrayList<ServiceComponentHost>(serviceComponentHostsByHost.get(hostname));
        }
        return new ArrayList<ServiceComponentHost>();
    } finally {
        clusterGlobalLock.readLock().unlock();
    }
}

From source file:org.kuali.student.enrollment.class2.courseoffering.controller.CourseOfferingRolloverController.java

@RequestMapping(params = "methodToCall=showRolloverResults")
public ModelAndView showRolloverResults(@ModelAttribute("KualiForm") CourseOfferingRolloverManagementForm form)
        throws Exception {
    //helper class for courseOfferingSetService
    CourseOfferingViewHelperService helper = CourseOfferingManagementUtil.getCoViewHelperService(form);
    //To fetch Term by code which is desirable.
    String targetTermCode = form.getRolloverTargetTermCode();
    List<TermInfo> termList = helper.findTermByTermCode(targetTermCode);
    if (termList.isEmpty()) {
        GlobalVariables.getMessageMap().putError("rolloverTargetTermCode",
                "error.rollover.targetTerm.noResults", targetTermCode);
        form.resetForm(); // TODO: Does this make sense?  I don't think so. cclin
        return getUIFModelAndView(form);
    } else {/* w ww  .j  av  a2s .  co m*/
        int firstValue = 0;
        TermInfo targetTerm = termList.get(firstValue);
        form.setTargetTerm(targetTerm);
        form.setTargetTermCode(targetTermCode);
        String targetTermId = targetTerm.getId();
        // Get rollover result info for target term
        List<SocRolloverResultInfo> socRolloverResultInfos = helper.findRolloverByTerm(targetTermId);
        if (socRolloverResultInfos == null || socRolloverResultInfos.isEmpty()) {
            GlobalVariables.getMessageMap().putError("rolloverTargetTermCode",
                    "error.rollover.targetTerm.noResults", targetTermCode);
            form.resetForm(); // TODO: Does this make sense?  I don't think so. cclin
            return getUIFModelAndView(form);
        } else {
            if (socRolloverResultInfos.size() > 1) {
                LOGGER.warn("Multiple Soc Rollover Results Found");
            }
            _disableReleaseToDeptsIfNeeded(helper, targetTermId, form);
            SocRolloverResultInfo socRolloverResultInfo = socRolloverResultInfos.get(firstValue);
            String stateKey = socRolloverResultInfo.getStateKey();
            _setStatus(stateKey, form);
            // SocInfo service to get Source Term Id
            SocInfo socInfo = CourseOfferingManagementUtil.getSocService()
                    .getSoc(socRolloverResultInfo.getSourceSocId(), new ContextInfo());
            // Put info in the display fields on the left hand side
            _displayRolloverInfo(socInfo, socRolloverResultInfo, form, helper, stateKey, targetTermId);

            // CourseOfferingSet service to get Soc Rollover ResultItems by socResultItemInfo id
            try {
                List<SocRolloverResultItemInfo> socRolloverResultItemInfos = CourseOfferingManagementUtil
                        .getSocService()
                        .getSocRolloverResultItemsByResultId(socRolloverResultInfo.getId(), new ContextInfo());
                List<SocRolloverResultItemInfo> socRolloverResultItemInfosCopy = new CopyOnWriteArrayList<SocRolloverResultItemInfo>(
                        socRolloverResultItemInfos);

                _displayRolloverItems(form, socRolloverResultItemInfos, socRolloverResultItemInfosCopy);
            } catch (UnhandledException ue) {
                throw new RuntimeException(ue);
            } catch (DoesNotExistException dne) {
                throw new RuntimeException(dne);
            }
        }
    }
    return getUIFModelAndView(form, ROLLOVER_DETAILS_PAGEID);
}

From source file:org.xmlsh.sh.shell.Shell.java

public void setArgs(List<XValue> args) {
    mArgs = new CopyOnWriteArrayList<>(args);

}

From source file:org.netbeans.jbpmn.modeler.specification.bpmn.model.process.util.BPMNProcessUtil.java

@Override
public void transformNode(IFlowNodeWidget flowNodeWidget, IModelerDocument document) {
    IModelerScene scene = flowNodeWidget.getModelerScene();

    NodeWidget sourceNodeWidget = (NodeWidget) flowNodeWidget;
    NodeWidgetInfo sourceNodeWidgetInfo = sourceNodeWidget.getNodeWidgetInfo();
    NodeWidgetInfo targetNodeWidgetInfo = null;

    targetNodeWidgetInfo = sourceNodeWidgetInfo.cloneNodeWidgetInfo();

    targetNodeWidgetInfo.setExist(Boolean.FALSE);
    SubCategoryNodeConfig subCategoryNodeConfig = scene.getModelerFile().getVendorSpecification()
            .getPaletteConfig().findSubCategoryNodeConfig(document);

    targetNodeWidgetInfo.setSubCategoryNodeConfig(subCategoryNodeConfig);

    INodeWidget targetNodeWidget = scene.createNodeWidget(targetNodeWidgetInfo);
    try {/*from ww  w.  jav  a2  s .  com*/
        BeanUtils.copyProperties(((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec(),
                ((IFlowNodeWidget) sourceNodeWidget).getBaseElementSpec());
    } catch (IllegalAccessException ex) {
        Exceptions.printStackTrace(ex);
    } catch (InvocationTargetException ex) {
        Exceptions.printStackTrace(ex);
    }

    ((IFlowNode) ((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec()).getIncoming().clear();
    ((IFlowNode) ((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec()).getOutgoing().clear();
    //clear incoming and outgoing reference because it is reconnected by following using visual api

    /* BUG : On transform , widget is Selected with resize border then [NodeWidget + border] width is calculated as bound */
    /*BUG Fix Start : Hide Resize border of all selected NodeWidget*/
    sourceNodeWidget.hideResizeBorder();
    scene.validate();
    /*BUG Fix End*/
    Rectangle bound = sourceNodeWidget.getSceneViewBound();
    Point location = sourceNodeWidget.getPreferredLocation();
    targetNodeWidgetInfo.setDimension(new Dimension(bound.width, bound.height));
    ((NodeWidget) targetNodeWidget).getNodeImageWidget().setDimension(new Dimension(bound.width, bound.height));

    if (((IFlowNodeWidget) sourceNodeWidget).getFlowElementsContainer() instanceof IModelerSubScene) {
        IModelerSubScene modelerSubScene = (IModelerSubScene) ((IFlowNodeWidget) sourceNodeWidget)
                .getFlowElementsContainer();
        ((NodeWidget) targetNodeWidget).setPreferredLocation(modelerSubScene.convertLocalToScene(location));
        ((SubProcessWidget) modelerSubScene).moveFlowNodeWidget((FlowNodeWidget) targetNodeWidget);
    } else {
        targetNodeWidget.setPreferredLocation(location);
    }

    if (flowNodeWidget instanceof FlowNodeWidget) {
        for (SequenceFlowWidget sequenceFlowWidget : new CopyOnWriteArrayList<SequenceFlowWidget>(
                ((FlowNodeWidget) flowNodeWidget).getIncomingSequenceFlows())) {
            NBModelerUtil.dettachEdgeTargetAnchor(scene, sequenceFlowWidget, sourceNodeWidget);
            NBModelerUtil.attachEdgeTargetAnchor(scene, sequenceFlowWidget, targetNodeWidget);
        }
        for (SequenceFlowWidget sequenceFlowWidget : new CopyOnWriteArrayList<SequenceFlowWidget>(
                ((FlowNodeWidget) flowNodeWidget).getOutgoingSequenceFlows())) {
            NBModelerUtil.dettachEdgeSourceAnchor(scene, sequenceFlowWidget, sourceNodeWidget);
            NBModelerUtil.attachEdgeSourceAnchor(scene, sequenceFlowWidget, targetNodeWidget);
        }
    }

    String name = ((IFlowNode) ((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec()).getName();
    if (name != null && !name.trim().isEmpty()) {
        ((INodeWidget) targetNodeWidget).setLabel(name);
    }

    sourceNodeWidget.remove();
    //        scene.revalidate();
    scene.validate();

}

From source file:org.netbeans.jbatch.modeler.specification.model.job.util.JobUtil.java

@Override
public void transformNode(IFlowNodeWidget flowNodeWidget, IModelerDocument document) {
    IModelerScene scene = flowNodeWidget.getModelerScene();

    NodeWidget sourceNodeWidget = (NodeWidget) flowNodeWidget;
    NodeWidgetInfo sourceNodeWidgetInfo = sourceNodeWidget.getNodeWidgetInfo();
    NodeWidgetInfo targetNodeWidgetInfo = null;

    targetNodeWidgetInfo = sourceNodeWidgetInfo.cloneNodeWidgetInfo();

    targetNodeWidgetInfo.setExist(Boolean.FALSE);
    SubCategoryNodeConfig subCategoryNodeConfig = scene.getModelerFile().getVendorSpecification()
            .getPaletteConfig().findSubCategoryNodeConfig(document);

    targetNodeWidgetInfo.setSubCategoryNodeConfig(subCategoryNodeConfig);

    INodeWidget targetNodeWidget = scene.createNodeWidget(targetNodeWidgetInfo);
    try {//  w  w w. j av  a  2 s.c  o m
        BeanUtils.copyProperties(((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec(),
                ((IFlowNodeWidget) sourceNodeWidget).getBaseElementSpec());
    } catch (IllegalAccessException ex) {
        Exceptions.printStackTrace(ex);
    } catch (InvocationTargetException ex) {
        Exceptions.printStackTrace(ex);
    }

    ((IFlowNode) ((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec()).getIncoming().clear();
    ((IFlowNode) ((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec()).getOutgoing().clear();
    //clear incoming and outgoing reference because it is reconnected by following using visual api

    /* BUG : On transform , widget is Selected with resize border then [NodeWidget + border] width is calculated as bound */
    /*BUG Fix Start : Hide Resize border of all selected NodeWidget*/
    sourceNodeWidget.hideResizeBorder();
    scene.validate();
    /*BUG Fix End*/
    Rectangle bound = sourceNodeWidget.getSceneViewBound();
    Point location = sourceNodeWidget.getPreferredLocation();
    targetNodeWidgetInfo.setDimension(new Dimension(bound.width, bound.height));
    ((NodeWidget) targetNodeWidget).getNodeImageWidget().setDimension(new Dimension(bound.width, bound.height));

    //        if (((IFlowNodeWidget) sourceNodeWidget).getFlowElementsContainer() instanceof IModelerSubScene) { //Sub_Commented
    //            IModelerSubScene modelerSubScene = (IModelerSubScene) ((IFlowNodeWidget) sourceNodeWidget).getFlowElementsContainer();
    //            ((NodeWidget) targetNodeWidget).setPreferredLocation(modelerSubScene.convertLocalToScene(location));
    //            ((SubProcessWidget) modelerSubScene).moveFlowNodeWidget((FlowNodeWidget) targetNodeWidget);
    //        } else {
    targetNodeWidget.setPreferredLocation(location);
    //        }

    if (flowNodeWidget instanceof FlowNodeWidget) {
        for (SequenceFlowWidget sequenceFlowWidget : new CopyOnWriteArrayList<SequenceFlowWidget>(
                ((FlowNodeWidget) flowNodeWidget).getIncomingSequenceFlows())) {
            NBModelerUtil.dettachEdgeTargetAnchor(scene, sequenceFlowWidget, sourceNodeWidget);
            NBModelerUtil.attachEdgeTargetAnchor(scene, sequenceFlowWidget, targetNodeWidget);
        }
        for (SequenceFlowWidget sequenceFlowWidget : new CopyOnWriteArrayList<SequenceFlowWidget>(
                ((FlowNodeWidget) flowNodeWidget).getOutgoingSequenceFlows())) {
            NBModelerUtil.dettachEdgeSourceAnchor(scene, sequenceFlowWidget, sourceNodeWidget);
            NBModelerUtil.attachEdgeSourceAnchor(scene, sequenceFlowWidget, targetNodeWidget);
        }
    }

    String name = ((IFlowNode) ((IFlowNodeWidget) targetNodeWidget).getBaseElementSpec()).getName();
    if (name != null && !name.trim().isEmpty()) {
        targetNodeWidget.setLabel(name);
    }

    sourceNodeWidget.remove();
    scene.validate();

}