How to design a class for managing file path? - oop

In my app, I generate some xml file for instance : "/xml/product/123.xml" where 123 is the product's id and 123.xml contains informations about this product. I also have "/xml/customer/123.xml" where 123.xml contains informations about the client ... 123
How can I manage these file paths :
I create the file path directly in the serialization method ?
I create 2 static classes : CustomerSerializationPathManager and ProductSerializationPathManager with 1 method : getPath(int customerID) and getPath(int productID)
I create one static class : SerializationPathManager with 2 methods : getCustomerPath(int customerID) and getProductPath(int productID)
Something else
I'd prefer solution 3 because if I think there's only one reason to change this class : I change the root directory.
So I'd like to have your thoughts about it... thx

If you need to save the files in specific folders and the location of these files can change, then you should move this information in a configuration file and later use if from there.
You then create a class similar to a factory, with getPathForProductExports, getPathForCustomerExports etc which reads the configuration file to return the desired path.
The configuration file can be a simple .properties file:
customer_path=/xml/customer/
product_path=/xml/product/
When generating the XML (be it customer, product or whatever) you prepend the appropriate path (getPathForCustomerExports, getPathForProductExports) to the file name.
If you later change the location you just edit the config file.

Related

Create a folder in DXL - DOORS

I am trying to make a script that will copy the contents of one project to another (ie folders and modules) in DXL. To do it, I have seen that there is the create function,
create(string name, string description)
which creates a folder... But from what I see, it creates it in the current directory where I run the script.
Is there any way that running the script in the M module, from the C folder of the P project, generates a folder with the same name C but inside the new NP project?
Thanks:)
from the DXL manual: The name argument can be an absolute or relative name, and may include the path.. So, you might have a loop like
Project P = project ('/P')
Item i
for i in P do {
if (type i == 'Folder') {
string nName = name i
create ("/NP/" sName, "")
}
// recursively copy the content of the folder
}
Also, depending on your needs, you might want to have a look at clipCopy and clipPaste, which duplicates an entire hierarchy.

Get File Structure from Get Metadata in ADF

I want to get the column names for a parquet file. I have a Get Metadata module in my pipeline and it is using a parquet dataset with only the root folder provided. Because only the folder is provided ADF is not letting me get the file structure that contains the column names. The file name is not provided because that can change. Can anyone provide some advice on how to approach this?
You will need 2 Get Metadata activities and a ForEach activity to get the file structure if your file name is not the same every time.
Source dataset:
Parameterize the file name as the name changes frequently.
Preview of source data:
Get Metadata1:
In the first Get Metadata activity, get the file name dynamically.
You can also specify if your file name contains any specific pattern by adding an expression in the filename or you can mention asterisk (*) if you don’t have a specific pattern or need more than 1 file in the folder needs to be processed.
Give field list as child items when you want to get the files from the folder.
Output of Get Metadata1: Get the file name from the folder.
FoEach activity:
Using the ForEach activity, you can get the item's name listed inside the Get Metadata activity output array.
Get Metadata2:
Add Get Metadata activity inside ForEach activity to get the file structure or column list of the current file from the folder. It can loop the number of items count in the folder (1 or more).
Output of Get Metadata2:
You can parameterize your file name in dataset or via GetMeta data activity, get the list of files within the folder and then via GetMetaData activity get the list of columns for those corresponding files.

How to document the structure type info in doxygen index.xml file

I defined a structure MY_STRUCTURE using typdef in .h file and created an instance MY_STRUCTURE MyStruct in .c file. I use Doxygen to output xml file.
My question is in the index.xml file, it only shows the structure instance name without showing its type.
<member refid="d6/d68/test_8c_1a89a9f154447f0a42e64c961660b4dd34" kind="variable"><name>MyStruct</name></member>
Without this info, I cannot link the structure instance name "MyStruct" with its type "MY_STRUCTURE".
Does anyone know how to link these two info in the output xml file?
Thanks
I can't find any option to add that info to the index file, so I don't think that is possible. You can however look up the type using the refid.
So given a member definition:
<member refid="main_8c_1ad514631b0d3cf856a07ef28509ad007a" kind="variable"><name>testStruct</name></member>
You can lookup in the file main_8c.xml(Should be d6/d86/test_8c.xml for you) the memberdef by matching id:
<sectiondef kind="var">
<memberdef kind="variable" id="main_8c_1ad514631b0d3cf856a07ef28509ad007a" prot="public" static="no" mutable="no">
<type><ref refid="structMY__STRUCTURE" kindref="compound">MY_STRUCTURE</ref></type>
<definition>MY_STRUCTURE testStruct</definition>

Jmeter : Number of active threads

I am using jmeter in elemetery freya (14.04)
I have a jmeter test plan with view results tree
I am trying to generate a csv file in view results tree including the number of active threads field.
It appears to me that the detail is being entered in the result.csv file, but the values representing this attribute has no field name, and hence that detail cannot be used in a graph which I want to create from the result.csv
I have changed JMETER-INSTALL-DIR/bin/jmeter.properties according to https://jmeter-plugins.org/wiki/PluginInstall/#Configure-JMeter
How can I get a result.csv file with a suitable fieldname like "active-threads"
Don't change anything in jmeter.properties file, upgrade to new JMeter version will discard your changes. Use user.properties file instead
The in order to add column names to CSV file add the following property to user.properties file:
jmeter.save.saveservice.print_field_names=true
Assuming good configuration you should be seeing grpThreads and allThreads columns along with the values.
See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of working with them

IntelliJ IDEA properties

In my project I'm frequently passing one AccountID in different packages and classes and that accountid is hardcoded wherever it used.
This AccountID may change for some resons in the future. And in order not to go over all files in my my project and replace it, I want to write it in one place.
I heard that there are some properties in IntelliJ where I can do that. I don't know how to google my problem, so if you have any sources, please share.
I think you should use the Properties.class for that purpose.
just write a txt file anywere (I recomend your Resources folder) and name it to "myProperties.properties" for instance
The text in your propertiefile would look like the following:
AccountID = "whateverIDyouWant"
to get the data of your propertiefile call:
Properties props = new Properties();
FileInputStream in = new FileInputStream("G:\\your\\path\\myProperties.properties");
props.load(in);
in.close();
String AccountID = props.getProperty("AccountID");
if your AccountID is an int just parse your string using Integer.parseInt(yourString);
if you want to set your properties through hard code, that can also be done:
props.setProperty("AccountID", "whateverIDyouWant");
Edit:
to create a resources folder, create a folder in your classpath. Afterwards go to the "Project view" in IntelliJ. Rightclick the new folder and select "Mark directory as" -> "Sources Root". Thats how its done.