forked from apache/hop
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Casters
committed
Jan 7, 2025
1 parent
1cbb1af
commit 2d59f4e
Showing
27 changed files
with
1,094 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core/src/main/java/org/apache/hop/core/variables/resolver/IVariableResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.hop.core.variables.resolver; | ||
|
||
import org.apache.hop.core.exception.HopException; | ||
import org.apache.hop.core.variables.IVariables; | ||
import org.apache.hop.metadata.api.HopMetadataObject; | ||
|
||
/** Indicates that the class can resolve variables in a specific manner. */ | ||
@HopMetadataObject(objectFactory = VariableResolverObjectFactory.class) | ||
public interface IVariableResolver { | ||
void init(); | ||
|
||
/** | ||
* Resolve the variables in the given String. | ||
* | ||
* @param string The String in which we want to replace variables. | ||
* @param variables The variables and values to use as a reference | ||
* @return The input string with expressions resolved. | ||
* @throws HopException In case something goes wrong. | ||
*/ | ||
String resolve(String string, IVariables variables) throws HopException; | ||
|
||
void setPluginId(); | ||
|
||
String getPluginId(); | ||
|
||
void setPluginName(String pluginName); | ||
|
||
String getPluginName(); | ||
} |
53 changes: 53 additions & 0 deletions
53
core/src/main/java/org/apache/hop/core/variables/resolver/VariableResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.hop.core.variables.resolver; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.hop.metadata.api.HopMetadata; | ||
import org.apache.hop.metadata.api.HopMetadataBase; | ||
import org.apache.hop.metadata.api.HopMetadataProperty; | ||
import org.apache.hop.metadata.api.HopMetadataPropertyType; | ||
import org.apache.hop.metadata.api.IHopMetadata; | ||
|
||
@HopMetadata( | ||
key = "variable-resolver", | ||
name = "i18n::VariableResolver.name", | ||
description = "i18n::VariableResolver.Description", | ||
image = "ui/images/variable.svg", | ||
documentationUrl = "/metadata-types/variable-resolver.html", | ||
hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION) | ||
@Getter | ||
@Setter | ||
public class VariableResolver extends HopMetadataBase implements IHopMetadata { | ||
public static final String GUI_PLUGIN_ELEMENT_PARENT_ID = | ||
"VariableResolver-PluginSpecific-Options"; | ||
|
||
@HopMetadataProperty private String description; | ||
|
||
@HopMetadataProperty(key = "variable-resolver") | ||
private IVariableResolver iResolver; | ||
|
||
public String getPluginName() { | ||
if (iResolver == null) { | ||
return null; | ||
} | ||
return iResolver.getPluginName(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
core/src/main/java/org/apache/hop/core/variables/resolver/VariableResolverObjectFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.hop.core.variables.resolver; | ||
|
||
import org.apache.hop.core.exception.HopException; | ||
import org.apache.hop.core.plugins.IPlugin; | ||
import org.apache.hop.core.plugins.PluginRegistry; | ||
import org.apache.hop.metadata.api.IHopMetadataObjectFactory; | ||
|
||
public class VariableResolverObjectFactory implements IHopMetadataObjectFactory { | ||
|
||
@Override | ||
public Object createObject(String id, Object parentObject) throws HopException { | ||
PluginRegistry registry = PluginRegistry.getInstance(); | ||
IPlugin plugin = registry.findPluginWithId(VariableResolverPluginType.class, id); | ||
return registry.loadClass(plugin); | ||
} | ||
|
||
@Override | ||
public String getObjectId(Object object) throws HopException { | ||
if (!(object instanceof IVariableResolver)) { | ||
throw new HopException( | ||
"Object is not of class IVariableResolver but of " + object.getClass().getName() + "'"); | ||
} | ||
return ((IVariableResolver) object).getPluginId(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
core/src/main/java/org/apache/hop/core/variables/resolver/VariableResolverPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.hop.core.variables.resolver; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** This annotation indicates that the given plugin is a variable resolver plugin. */ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface VariableResolverPlugin { | ||
/** | ||
* @return The ID of the password encoder plugin. You can specify more than one ID in a comma | ||
* separated format: id1,id2,id3 for deprecation purposes. | ||
*/ | ||
String id(); | ||
|
||
String name(); | ||
|
||
String description() default ""; | ||
|
||
/** | ||
* @return True if a separate class loader is needed every time this class is instantiated | ||
*/ | ||
boolean isSeparateClassLoaderNeeded() default false; | ||
|
||
String documentationUrl() default ""; | ||
|
||
String casesUrl() default ""; | ||
|
||
String forumUrl() default ""; | ||
|
||
String classLoaderGroup() default ""; | ||
} |
Oops, something went wrong.