DotNetNuke List Export as csv - dotnetnuke

We are using Forms and list module in DNN 9 portal. We are having List with URL column. We are able to view the URL value in portal. But, when we export list as csv and If URL value is internal URL(like Portal page URL or file URL), then we get some integer instead of URL, in exported csv. Is there a way to get proper URL in csv file? Any suggestions?

The integer is probably the TabId. So you might be able to crest a SQL script that does an inner join with the tabs table.
If other URLs are mixed with integers, possibly create a function to be called if you get an integer. Depending on the size of the list, it might take time, but should work.

It is the TabId. As Joe said, depending on the number of cases it might be some work. If it is only a handful, it could be easier to manually replace the handful of integers by the Url itself.
In addition to Joe's answer:
To get the Url, you could use the following SQL script:
SELECT
'https://' + pa.HTTPAlias + tu.[Url] AS [Url]
FROM
{databaseOwner}{objectQualifier}Tabs t
INNER JOIN {databaseOwner}{objectQualifier}TabUrls tu ON tu.TabId = t.TabID
INNER JOIN {databaseOwner}{objectQualifier}Portals p ON p.PortalID = t.PortalID
INNER JOIN {databaseOwner}{objectQualifier}PortalAlias pa ON pa.PortalID = p.PortalID
WHERE
t.IsDeleted = 0
AND t.DisableLink = 0
AND tu.HttpStatus = 200
AND pa.IsPrimary = 1
AND t.TabID = [THE INTEGER GOES HERE]
Run this script in the DNN SQL Console, if you use SSMS you have to change {databaseOwner} and {objectQualifier} by the approbriate values that you find in the web.config file. Add a dot (".") after the {databaseOwner} value, eg. "dbo."
If you are not using https change the string to 'http://'.

Related

SQL - trying to find a set of data which only has a certain set of values but not anything else in a few columns

Hopefully an easy problem for an experienced SQL person. I have an application which uses SQL Server, and I cannot perform this query in the application, so I'm hoping to back-door it, but I need help.
I have a table with a large list of emails and all its metadata. I'm trying to find email that is only between parties of this one company and flag them.
What I did was search where companyName.com is in To and From and marked a TagField as 1 (I did this through my application's front end).
Now what I need to do is search where any other possible values, ignoring companyName.com exist in To and From where I've already flagged them as 1 in TagField. From will usually just have one value, but To could have multiple, all formatted differently, but all separated by a semi-colon (I will probably have to apply this same search to CC and BCC columns, too).
Any thoughts?
Replace the ; with the empty string. Then check to see if the length changed. If there's one email address, there shouldn't be a ';'. You could also use the same technique to replace the company name with the empty string. Anything left would be the other companies.
select email_id, to_email
from yourtable
where TagField = 1 and len(to_email) <> len(replace(to_email,';',''))
This solution is based on the following thread
Number of times a particular character appears in a string
So I went an entirely different route and exported my data to a CSV and used Python to get to where I needed. Here's the code I used in case anybody needs it. What this returned for me was a list of DocIDs (unique identifiers that were in the CSV) where ever there was an email address in the To field that wasn't from one specific domain. I went into the original CSV and made sure all instances of this domain name were in all lowercase, too.
import csv
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
sub = "domainname"
def findMultipleTo(dict):
for row in reader:
if row['To'].find(";") != -1:
toArray = row['To'].split(';')
newTo = [s for s in toArray if sub not in s]
row['To'] = newTo
else:
row['To'] = 'empty'
with open('location\\newCSV-BCCFieldSearch.csv', 'a') as f:
if row['To'] != "empty" and row['To'] != []:
print(row['DocID'], row['To'], file = f)
else:
pass
with open(file_path) as csvfile:
reader = csv.DictReader(csvfile)
findMultipleTo(reader)

Return list of objects in Hibernate

I'm writing an application that use Hibernate to query the database (SQL Server).
Now I'm querying a link table for all Items.
The query looks like:
"FROM UserRole ur join ur.platformUser join ur.role join ur.company"
I need all the UserRoles objects in a list but when I query the above query I got a arrao of objects with UserRole, Role, Company and PlatformUser objects in it.
I only need the UserRole objects with the other objects in the UserRole object.
How can I solve this in Hiernate that I can cast the result to for ex. Arraylist<UserRole>?
I tried following syntax:
Query query = session.createSQLQuery("select * FROM UserRole ur join PlatformUser pu ON pu.userId = ur.userId join [Role] r ON r.roleId = ur.roleId join [Company] c ON c.companyId = ur.companyId").addEntity(UserRole.class);
With this line I got a List of UserRoles but all the underlying objects are NULL.
It could be that you've mapped the fields in the UserRole as lazy loaded? (Or haven't specified, I believe lazy loading is the default)
Try writing something along the lines of
Object obj = userRoles.get(0).getName(); //Or any of the previously null valued fields you have in there
Make sure you're writing this still within session, preferably right after the query.list(); itself
That should lazy load the value, and if that was indeed the case, look into initializing hibernate objects.
edit:
If you're looking for a more proper way of doing this, there's actually a hibernate method that requests to initialize a proxy object, I'm unsure why it's better than just getting the thing you want to initialize from code, but it sure is prettier.
Hibernate.initialize(Object initializeMe)
But as far as I know, it's a shallow method, meaning it won't load entities inside of this one. To achieve that you'll need to either do it by hand, or make a generic method that'll load everything, think reflection & recursive.

OrientDB - find "orphaned" binary records

I have some images stored in the default cluster in my OrientDB database. I stored them by implementing the code given by the documentation in the case of the use of multiple ORecordByte (for large content): http://orientdb.com/docs/2.1/Binary-Data.html
So, I have two types of object in my default cluster. Binary datas and ODocument whose field 'data' lists to the different record of binary datas.
Some of the ODocument records' RID are used in some other classes. But, the other records are orphanized and I would like to be able to retrieve them.
My idea was to use
select from cluster:default where #rid not in (select myField from MyClass)
But the problem is that I retrieve the other binary datas and I just want the record with the field 'data'.
In addition, I prefer to have a prettier request because I don't think the "not in" clause is really something that should be encouraged. Is there something like a JOIN which return records that are not joined to anything?
Can you help me please?
To resolve my problem, I did like that. However, I don't know if it is the right way (the more optimized one) to do it:
I used the following SQL request:
SELECT rid FROM (FIND REFERENCES (SELECT FROM CLUSTER:default)) WHERE referredBy = []
In Java, I execute it with the use of the couple OCommandSQL/OCommandRequest and I retrieve an OrientDynaElementIterable. I just iterate on this last one to retrieve an OrientVertex, contained in another OrientVertex, from where I retrieve the RID of the orpan.
Now, here is some code if it can help someone, assuming that you have an OrientGraphNoTx or an OrientGraph for the 'graph' variable :)
String cmd = "SELECT rid FROM (FIND REFERENCES (SELECT FROM CLUSTER:default)) WHERE referredBy = []";
List<String> orphanedRid = new ArrayList<String>();
OCommandRequest request = graph.command(new OCommandSQL(cmd));
OrientDynaElementIterable objects = request.execute();
Iterator<Object> iterator = objects.iterator();
while (iterator.hasNext()) {
OrientVertex obj = (OrientVertex) iterator.next();
OrientVertex orphan = obj.getProperty("rid");
orphanedRid.add(orphan.getIdentity().toString());
}

bulk remove the required paramater fron custom option magento

i have around 10000 products in my database which all have custom options and they all are set to required.
I need to unset required.
Please suggest me how can i do this dynamically.
I don't want to do it one by one from magento admin because that will take forever
thanks
If you want to reset the required field for all custom options of all products here is a quick & dirty way of doing it.
All the custom options are stored in the table catalog_product_option.
The column name that decides if the option is required or not is is_require.
So running this query should do the trick.
UPDATE `catalog_product_option` SET `is_require` = 0 WHERE 1
Add the table prefix if you have one.
you can update those product's required parameter by using import product by csv. I think, you have imported products by csv. simply copy that SKU and custom field option into new csv file.
And import Again those products. It will update custom option required field as you want
I'm just expanding on Marius' answer. I needed to do this but only for a bunch of custom options I'd made required by accident. I figure it might help someone else who made a similar miscalculation! :-D
UPDATE catalog_product_option o
JOIN catalog_product_option_title t ON t.option_id=o.option_id
SET o.is_require = 0
WHERE t.title = 'Additional Comments'
AND o.is_require = 1
Luckily the options I imported all had the same title so I was able to filter it that way.
If you're using SKU's for your custom options, you could probably further simplify the query as it requires no joins.
UPDATE catalog_product_option o
SET o.is_require = 0
WHERE o.sku = 'SKU1234'
AND o.is_require = 1
^ not tested that but looking at the structure of the table that should work.

How to match text in cmsplugin_text table to URL in Django CMS

We have created a site for a client using Django CMS and are approaching the launch date. There are a number of links to files on their old site. Doing a search of the cmsplugin_text table, I find 12 entries that contain the URL. There is no simple mapping to the new file download URL from the old download URL, so I need to find the pages these 12 entries appear on and tell our client so they can edit the page.
But the database is not easy to follow. So how do I go from the value of the cmsplugin_ptr_id column of the cmsplugin_text column to the URL of the page? I'm fairly sure that the cmsplugin_ptr_id is meant to line up with the id of the cms_cmsplugin table. That table also has parent_id, tree_id and placeholder_id, but I've kind of got lost at this point.
I'm happy to use either the database commands directly, or to use manage.py shell to do this.
Should have tried a bit harder before answering.
The steps that worked were to look in cms_page_placeholder for lines with the placeholder_id and look up the corresponding page_id. I could then look up the page in the admin at http://mysite.com/en/admin/cms/page/page_id and that page has a "View on site link".
The SQL statement I used was:
SELECT cpp.page_id
FROM cmsplugin_text AS cpt
LEFT JOIN cms_cmsplugin AS ccp ON cpt.cmsplugin_ptr_id = ccp.id
LEFT JOIN cms_page_placeholders AS cpp ON ccp.placeholder_id = cpp.placeholder_id
WHERE cpt.body like '%userfiles%';
Where userfiles was part of the path to the files on the old site.

Resources