Skip to content

Commit

Permalink
Release/v1.2.0 is prepared
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed Mar 13, 2024
2 parents 0834e05 + 0d9cf09 commit 784a60e
Show file tree
Hide file tree
Showing 54 changed files with 1,040 additions and 263 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ apply(plugin = "org.jetbrains.intellij")
apply(from = "gradle/sonar.gradle")

group = "org.zowe"
version = "1.1.3-221"
version = "1.2.0-221"
val remoteRobotVersion = "0.11.21"
val okHttp3Version = "4.12.0"
val kotestVersion = "5.6.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/
package org.zowe.explorer.dataops.operations.mover.names

import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.vfs.VirtualFile
import org.zowe.explorer.dataops.DataOpsComponentFactory

interface CopyPasteNameResolverFactory: DataOpsComponentFactory<CopyPasteNameResolver>

/**
* Class to represent a name resolution for conflicting situation.
* @author Valiantsin Krus
*/
interface CopyPasteNameResolver {
companion object {
@JvmField
val EP = ExtensionPointName.create<CopyPasteNameResolverFactory>("org.zowe.explorer.nameResolver")
}

/**
* Determines whether this name resolver could resolve conflict for passed files or not.
* @param source source file to copy in destination folder (or folder-like entity).
* @param destination folder-like entity to copy file to.
* @return true if this name resolver could dot it or false otherwise.
*/
fun accepts(source: VirtualFile, destination: VirtualFile): Boolean

/**
* Finds child in destination folder that conflicts with source file.
* @param source source file to copy in destination folder (or folder-like entity).
* @param destination folder-like entity to copy file to.
* @return instance of conflicting child file or null if it was not found.
*/
fun getConflictingChild(source: VirtualFile, destination: VirtualFile): VirtualFile?

/**
* Creates new name for source file to make it possible to be copied in destination folder.
* @param source source file to copy in destination folder (or folder-like entity).
* @param destination folder-like entity to copy file to.
* @return string with new file name.
*/
fun resolve(source: VirtualFile, destination: VirtualFile): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/
package org.zowe.explorer.dataops.operations.mover.names

import com.intellij.openapi.vfs.VirtualFile
import org.zowe.explorer.dataops.DataOpsManager
import org.zowe.explorer.dataops.attributes.RemoteDatasetAttributes

class DatasetOrDirResolverFactory : CopyPasteNameResolverFactory {
override fun buildComponent(dataOpsManager: DataOpsManager): CopyPasteNameResolver {
return DatasetOrDirResolver(dataOpsManager)
}
}

/**
* Implementation of [CopyPasteNameResolver] for copying dataset or directory to uss or local system.
* @author Valiantsin Krus
*/
class DatasetOrDirResolver(val dataOpsManager: DataOpsManager): IndexedNameResolver() {
override fun accepts(source: VirtualFile, destination: VirtualFile): Boolean {
val sourceAttributes = dataOpsManager.tryToGetAttributes(source)
val destinationAttributes = dataOpsManager.tryToGetAttributes(destination)
return (source.isDirectory || sourceAttributes is RemoteDatasetAttributes) && destinationAttributes !is RemoteDatasetAttributes
}


override fun resolveNameWithIndex(source: VirtualFile, destination: VirtualFile, index: Int?): String {
return if (index == null) source.name else "${source.name}_(${index})"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/
package org.zowe.explorer.dataops.operations.mover.names

import com.intellij.openapi.vfs.VirtualFile

/**
* Implementation of [IndexedNameResolver] that is used by default (if no one other name resolver was found)
* It just adds _(<index>) to the end of the file name before extension.
* @author Valiantsin Krus
*/
class DefaultNameResolver: IndexedNameResolver() {
override fun accepts(source: VirtualFile, destination: VirtualFile): Boolean {
return true
}

override fun resolveNameWithIndex(source: VirtualFile, destination: VirtualFile, index: Int?): String {
val sourceName = source.name
return if (index == null) {
sourceName
} else {
val extension = if (sourceName.contains(".")) sourceName.substringAfterLast(".") else null
val newNameWithoutExtension = "${sourceName.substringBeforeLast(".")}_(${index})"
if (extension != null) "$newNameWithoutExtension.$extension" else newNameWithoutExtension
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/
package org.zowe.explorer.dataops.operations.mover.names

import com.intellij.openapi.vfs.VirtualFile

/**
* Name resolver that generates new name based on the index (e.g. file_(1), file_(2) and etc.)
* This is an abstract class, it only finds the necessary index but doesn't create a new name.
* It could be, for example file1, file2, file3. It all depends on implementation needs.
* @author Valiantsin Krus
*/
abstract class IndexedNameResolver: CopyPasteNameResolver {

override fun getConflictingChild(source: VirtualFile, destination: VirtualFile): VirtualFile? {
val rowNameToCopy = resolveNameWithIndex(source, destination, null)
return destination.children.firstOrNull { it.name == rowNameToCopy }
}

/**
* Creates new name for a source file based on passed index.
* @param source source file to copy in destination folder (or folder-like entity).
* @param destination folder-like entity to copy file to.
* @param index generated index to add to the source name. If it is null, then no index is needed to add.
* @return new name with joined index.
*/
abstract fun resolveNameWithIndex(source: VirtualFile, destination: VirtualFile, index: Int?): String

override fun resolve(source: VirtualFile, destination: VirtualFile): String {
var newName = resolveNameWithIndex(source, destination, null)
var index = 1
while (destination.children.any { it.name == newName }) {
newName = resolveNameWithIndex(source, destination, index++)
}
return newName
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/
package org.zowe.explorer.dataops.operations.mover.names

import com.intellij.openapi.vfs.VirtualFile
import org.zowe.explorer.dataops.DataOpsManager
import org.zowe.explorer.dataops.attributes.RemoteDatasetAttributes

class NotSeqToPDSResolverFactory : CopyPasteNameResolverFactory {
override fun buildComponent(dataOpsManager: DataOpsManager): CopyPasteNameResolver {
return NotSeqToPDSResolver(dataOpsManager)
}
}

/**
* Implementation of [CopyPasteNameResolver] for copying anything except of Sequential Dataset to PDS.
* @author Valiantsin Krus
*/
class NotSeqToPDSResolver(val dataOpsManager: DataOpsManager) : IndexedNameResolver() {
override fun accepts(source: VirtualFile, destination: VirtualFile): Boolean {
val sourceAttributes = dataOpsManager.tryToGetAttributes(source)
val destinationAttributes = dataOpsManager.tryToGetAttributes(destination)
return destinationAttributes is RemoteDatasetAttributes &&
sourceAttributes !is RemoteDatasetAttributes
}

override fun resolveNameWithIndex(source: VirtualFile, destination: VirtualFile, index: Int?): String {
val memberName = source.name.filter { it.isLetterOrDigit() }.uppercase().ifEmpty { "EMPTY" }
return if (index == null) memberName.take(8) else "${memberName.take(7)}$index"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/
package org.zowe.explorer.dataops.operations.mover.names

import com.intellij.openapi.vfs.VirtualFile
import org.zowe.explorer.dataops.DataOpsManager
import org.zowe.explorer.dataops.attributes.RemoteDatasetAttributes

class SeqToPDSResolverFactory : CopyPasteNameResolverFactory {
override fun buildComponent(dataOpsManager: DataOpsManager): CopyPasteNameResolver {
return SeqToPDSResolver(dataOpsManager)
}
}

/**
* Implementation of [CopyPasteNameResolver] for copying Sequential Dataset to PDS.
* @author Valiantsin Krus
*/
class SeqToPDSResolver(val dataOpsManager: DataOpsManager) : IndexedNameResolver() {
override fun accepts(source: VirtualFile, destination: VirtualFile): Boolean {
val sourceAttributes = dataOpsManager.tryToGetAttributes(source)
val destinationAttributes = dataOpsManager.tryToGetAttributes(destination)
return sourceAttributes is RemoteDatasetAttributes &&
!source.isDirectory &&
destinationAttributes is RemoteDatasetAttributes
}

override fun resolveNameWithIndex(source: VirtualFile, destination: VirtualFile, index: Int?): String {
val lastQualifier = source.name.split(".").last()
return if (index == null) lastQualifier else "${lastQualifier.take(7)}${index}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.zowe.explorer.dataops.DataOpsManager
import org.zowe.explorer.dataops.operations.*
import org.zowe.explorer.utils.*
import org.zowe.explorer.utils.crudable.Crudable
import org.zowe.explorer.utils.crudable.find
import org.zowe.explorer.utils.crudable.getAll
import org.zowe.kotlinsdk.ChangePassword
import org.zowe.kotlinsdk.annotations.ZVersion
Expand All @@ -53,7 +54,11 @@ class ConnectionDialog(
* Private field
* In case of DialogMode.UPDATE takes the last successful state from crudable, takes default state otherwise
*/
private val lastSuccessfulState: ConnectionDialogState = if(state.mode == DialogMode.UPDATE) state.connectionConfig.toDialogState(crudable) else ConnectionDialogState()
private val lastSuccessfulState: ConnectionDialogState =
if(state.mode == DialogMode.UPDATE) crudable.find<ConnectionConfig> { it.uuid == state.connectionUuid }
.findAny()
.orElseGet { state.connectionConfig }
.toDialogState(crudable) else ConnectionDialogState()
companion object {

/** Show Test connection dialog and test the connection regarding the dialog state.
Expand Down
17 changes: 17 additions & 0 deletions src/main/kotlin/org/zowe/explorer/config/ws/ui/AbstractWsDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ abstract class AbstractWsDialog<Connection : ConnectionConfigBase, WSConfig : Wo
var initialState: WSDState = state.clone(wsdStateClass)
) : DialogWrapper(false), StatefulComponent<WSDState> {

companion object {

// TODO: Remove when it becomes possible to mock class constructor with init section.
/** Wrapper for init() method. It is necessary only for test purposes for now. */
private fun initialize(init: () -> Unit) {
init()
}
}

abstract val wsConfigClass: Class<out WSConfig>
abstract val connectionClass: Class<out Connection>

Expand Down Expand Up @@ -155,6 +164,14 @@ abstract class AbstractWsDialog<Connection : ConnectionConfigBase, WSConfig : Wo
}
}

/** Register validator that enables OK action if validation map is empty */
override fun init() {
initialize { super.init() }
panel.registerValidators(myDisposable) { map ->
isOKActionEnabled = map.isEmpty()
}
}

override fun createCenterPanel(): JComponent {
return panel
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/org/zowe/explorer/dataops/DataOpsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.zowe.explorer.dataops.fetch.FileFetchProvider
import org.zowe.explorer.dataops.log.LogFetcher
import org.zowe.explorer.dataops.log.MFLogger
import org.zowe.explorer.dataops.log.MFProcessInfo
import org.zowe.explorer.dataops.operations.mover.names.CopyPasteNameResolver

interface DataOpsManager : Disposable {

Expand Down Expand Up @@ -65,6 +66,8 @@ interface DataOpsManager : Disposable {

fun getMFContentAdapter(file: VirtualFile): MFContentAdapter

fun getNameResolver(source: VirtualFile, destination: VirtualFile): CopyPasteNameResolver

fun isOperationSupported(operation: Operation<*>): Boolean

@Throws(Throwable::class)
Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/org/zowe/explorer/dataops/DataOpsManagerImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import org.zowe.explorer.dataops.log.LogFetcher
import org.zowe.explorer.dataops.log.MFLogger
import org.zowe.explorer.dataops.log.MFProcessInfo
import org.zowe.explorer.dataops.operations.OperationRunner
import org.zowe.explorer.dataops.operations.mover.names.CopyPasteNameResolver
import org.zowe.explorer.dataops.operations.mover.names.DefaultNameResolver
import org.zowe.explorer.utils.associateListedBy
import org.zowe.explorer.utils.findAnyNullable
import org.zowe.explorer.utils.log
Expand Down Expand Up @@ -137,6 +139,15 @@ class DataOpsManagerImpl : DataOpsManager {
}
private val mfContentAdapters by mfContentAdaptersDelegate

private val nameResolversDelegate = lazy {
CopyPasteNameResolver.EP.extensionList.buildComponents()
}
private val nameResolvers by nameResolversDelegate

override fun getNameResolver(source: VirtualFile, destination: VirtualFile): CopyPasteNameResolver {
return nameResolvers.firstOrNull { it.accepts(source, destination) } ?: DefaultNameResolver()
}

/**
* Checks if sync with mainframe is supported for provided object
* @param file object on mainframe that should be checked on availability of synchronization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ interface ContentSynchronizer {
*/
fun isFileUploadNeeded(syncProvider: SyncProvider): Boolean

/**
* Marks file as not needed for synchronisation until the next time file is modified.
* @param syncProvider instance of [SyncProvider] class that contains file to mark.
*/
fun markAsNotNeededForSync(syncProvider: SyncProvider)

}
Loading

0 comments on commit 784a60e

Please sign in to comment.