Search in sources :

Example 1 with GetSerialInfoListTask

use of com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask in project cubrid-manager by CUBRID.

the class ExportSchemaThread method exportSerial.

/**
	 * exportSerial
	 *
	 * @param serialFilePath
	 * @throws Exception
	 */
private void exportSerial(String serialFilePath) throws Exception {
    // FIXME move this logic to core module
    BufferedWriter fs = null;
    boolean hasSerial = false;
    File serialFile = null;
    try {
        fs = FileUtil.getBufferedWriter(serialFilePath, exportConfig.getFileCharset());
        if (exportConfig.isExportSerial()) {
            GetSerialInfoListTask task = new GetSerialInfoListTask(dbInfo);
            task.execute();
            for (SerialInfo serial : task.getSerialInfoList()) {
                fs.write(createSerialSQLScript(serial, dbInfo));
                fs.write(StringUtil.NEWLINE);
                hasSerial = true;
            }
            fs.flush();
        }
    } finally {
        try {
            if (fs != null) {
                fs.close();
            }
        } catch (IOException e) {
            LOGGER.error("", e);
        }
        if (!hasSerial) {
            if (serialFile != null) {
                serialFile.delete();
            }
        }
    }
}
Also used : GetSerialInfoListTask(com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask) IOException(java.io.IOException) SerialInfo(com.cubrid.common.core.common.model.SerialInfo) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 2 with GetSerialInfoListTask

use of com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask in project cubrid-manager by CUBRID.

the class CubridSerialFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            database.getDatabaseInfo().setSerialInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetSerialInfoListTask task = new GetSerialInfoListTask(databaseInfo);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        List<SerialInfo> serialInfoList = task.getSerialInfoList();
        List<SerialInfo> authSerialInfoList = new ArrayList<SerialInfo>();
        if (serialInfoList != null && !serialInfoList.isEmpty()) {
            for (SerialInfo serialInfo : serialInfoList) {
                authSerialInfoList.add(serialInfo);
                String id = parent.getId() + NODE_SEPARATOR + serialInfo.getName();
                ICubridNode serialNode = createSerialNode(id, serialInfo);
                parent.addChild(serialNode);
            }
        }
        databaseInfo.setSerialInfoList(authSerialInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : GetSerialInfoListTask(com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ArrayList(java.util.ArrayList) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SerialInfo(com.cubrid.common.core.common.model.SerialInfo)

Example 3 with GetSerialInfoListTask

use of com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask in project cubrid-manager by CUBRID.

the class OpenSerialDetailInfoPartProgress method run.

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final GetSerialInfoListTask task = new GetSerialInfoListTask(database.getDatabaseInfo());
    task.execute();
    if (!(task.isSuccess())) {
        LOGGER.error(task.getErrorMsg());
        return;
    }
    serialList = task.getSerialInfoList();
    success = true;
}
Also used : GetSerialInfoListTask(com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask)

Aggregations

GetSerialInfoListTask (com.cubrid.cubridmanager.core.cubrid.serial.task.GetSerialInfoListTask)3 SerialInfo (com.cubrid.common.core.common.model.SerialInfo)2 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1