Skip to content

Commit

Permalink
Merge pull request #4717 from hansva/4712
Browse files Browse the repository at this point in the history
Revert and change folders for metadata items, #4712
  • Loading branch information
hansva authored Dec 17, 2024
2 parents fe080d9 + 2291fa6 commit 3fff269
Show file tree
Hide file tree
Showing 20 changed files with 287 additions and 698 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,4 @@
* @return the type of metadata this property represents.
*/
HopMetadataPropertyType hopMetadataPropertyType() default HopMetadataPropertyType.NONE;

/**
* A boolean flag, represented as a string, which tells whether the given HopMetadata
* implementation has to be shown into a tree of folders
*
* @return a boolean as string flag that will enable the UI to allow folders creation
*/
String subfoldersEnabled() default "false";
}
45 changes: 30 additions & 15 deletions core/src/main/java/org/apache/hop/metadata/api/HopMetadataBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@

public class HopMetadataBase implements IHopMetadata {

@HopMetadataProperty protected String path;

/** All metadata objects have a name to uniquely identify it. */
@HopMetadataProperty protected String name;

/** All metadata objects can have a virtual path to organize them */
@HopMetadataProperty protected String virtualPath;

/**
* The metadata provider name is optionally used at runtime to figure out where the metadata came
* from. Optionally used by plugins. It's volatile because it's never persisted.
Expand All @@ -38,13 +39,13 @@ public HopMetadataBase() {}
public HopMetadataBase(String name) {
this();
this.name = name;
this.path = "";
this.virtualPath = "";
}

public HopMetadataBase(String name, String path) {
public HopMetadataBase(String name, String virtualPath) {
this();
this.name = name;
this.path = path;
this.virtualPath = virtualPath;
}

@Override
Expand Down Expand Up @@ -106,26 +107,40 @@ public void setMetadataProviderName(String metadataProviderName) {
this.metadataProviderName = metadataProviderName;
}

/**
* Get the virtual path set on a metadata item
*
* @return a String representing the virtual path
*/
@Override
public String getPath() {
return path;
public String getVirtualPath() {
return virtualPath;
}

/**
* Set the virtual path on a metadata item
*
* @param virtualPath the virtual path to set to the metadata item
*/
@Override
public void setPath(String path) {
this.path = path;
public void setVirtualPath(String virtualPath) {
this.virtualPath = virtualPath;
}

/**
* Return the virtual path and name of the object
*
* @return the virtual path and name of the object
*/
@Override
public String getFullName() {
if (path == null || path.isBlank()) {
if (virtualPath == null || virtualPath.isEmpty()) {
return name;
}
if (virtualPath.endsWith("/")) {
return virtualPath + name;
} else {
if (path.endsWith("/")) {
return path + name;
} else {
return path + "/" + name;
}
return virtualPath + "/" + name;
}
}
}
17 changes: 15 additions & 2 deletions core/src/main/java/org/apache/hop/metadata/api/IHopMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,22 @@ public interface IHopMetadata {
*/
void setMetadataProviderName(String metadataProviderName);

String getPath();
/**
* @return the virtual path for organizing metadata items
*/
String getVirtualPath();

void setPath(String path);
/**
* Set the virtual path on a metadata item
*
* @param virtualPath the virtual path to set to the metadata item
*/
void setVirtualPath(String virtualPath);

/**
* Get the complete name of the object (virtual path + name)
*
* @return the full name of the object
*/
String getFullName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.util.List;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.metadata.serializer.FileSystemNode;

/**
* This metadata interface describes how an object T can be serialized and analyzed.
Expand Down Expand Up @@ -68,11 +67,6 @@ public interface IHopMetadataSerializer<T extends IHopMetadata> {
*/
List<String> listObjectNames() throws HopException;

default FileSystemNode getFileSystemTree() throws HopException {
throw new UnsupportedOperationException(
"listObjectNames(String folderName, Boolean recursive) is not supported by this metadata serializer");
}

/**
* See if an object with the given name exists.
*
Expand Down

This file was deleted.

Loading

0 comments on commit 3fff269

Please sign in to comment.