talk@lists.collectionspace.org

WE HAVE SUNSET THIS LISTSERV - Join us at collectionspace@lyrasislists.org

View all threads

Erase all records at one time

ST
Sandra Tsai
Thu, Oct 11, 2012 6:18 PM

Hi CollectionSpacers,

We use CollectionSpace version 2.5. We have a question about how
to erase all records in CollectionSpace at one time.

Thanks so much!
Sandra Tsai

Hi CollectionSpacers, We use CollectionSpace version 2.5. We have a question about how to erase all records in CollectionSpace at one time. Thanks so much! Sandra Tsai
AR
Aron Roberts
Thu, Oct 11, 2012 8:11 PM

On Thu, Oct 11, 2012 at 11:18 AM, Sandra Tsai sandrayun.tsai@gmail.com wrote:

We use CollectionSpace version 2.5. We have a question about how to erase
all records in CollectionSpace at one time.

First, if all you want to do is selectively delete records, and you
know - or can obtain - their unique identifiers (CSIDs) in your
system, there's a script here for doing exactly that:

http://wiki.collectionspace.org/display/CSPACE25/How+to+Import+Data

Alternately, could you be working in a setting, Sandra, where you're
testing data import / data loading on a non-production system, and
occasionally want to quickly wipe out all records and start completely
fresh?

If that's the case, and you truly want to delete all object,
procedural, authority/vocabulary term, and relationship records
throughout CollectionSpace, while retaining user and account
information, you could:

After doing so, you may also need to re-create some standard system
data before you begin importing / data loading.  At a minimum:

  • You will likely need to re-create your authorities and
    vocabularies, so that you can once again save and import records into
    those.  If you're using just the default set of authorities and
    vocabularies, rather than having created your own, you can now
    conveniently re-create these in every tenant via a script
    (http://issues.collectionspace.org/browse/CSPACE-5285).

Or you can do the same thing by following the instructions under
"Initializing default authorities and term lists" near the end of
http://wiki.collectionspace.org/display/CSPACE25/Installing+2.5+on+Generic+Unix-like+or+Windows+Systems,
while noting that you'll need to do this within your own tenant, by
substituting your tenant's identifier for 'core' in those
instructions.

Aron

P.S.  There is an unresolved JIRA to make it convenient, via a call to
the CollectionSpace services layer, to selectively delete all records
of a particular record type:

http://issues.collectionspace.org/browse/CSPACE-2948

On Thu, Oct 11, 2012 at 11:18 AM, Sandra Tsai <sandrayun.tsai@gmail.com> wrote: > We use CollectionSpace version 2.5. We have a question about how to erase > all records in CollectionSpace at one time. First, if all you want to do is selectively delete records, and you know - or can obtain - their unique identifiers (CSIDs) in your system, there's a script here for doing exactly that: http://wiki.collectionspace.org/display/CSPACE25/How+to+Import+Data Alternately, could you be working in a setting, Sandra, where you're testing data import / data loading on a *non-production* system, and occasionally want to quickly wipe out all records and start completely fresh? If that's the case, and you truly want to delete all object, procedural, authority/vocabulary term, and relationship records throughout CollectionSpace, while retaining user and account information, you could: * Download the Services source code (http://wiki.collectionspace.org/display/CSPACE25/How+to+check+out+the+Services+layer+source+code) * Shut down the CollectionSpace servers (http://wiki.collectionspace.org/display/CSPACE25/Shutting+Down+CollectionSpace+Servers) * From the top level of the Services source code tree, type "ant create_nuxeo_db". This will drop and re-create the 'nuxeo' database, in which most of CollectionSpace's records reside. (WARNING WARNING This will truly wipe the aforementioned data; these records will only be capable of being restored from backup.) * Restart the CollectionSpace servers (http://wiki.collectionspace.org/display/CSPACE25/Starting+Up+CollectionSpace+Servers) After doing so, you may also need to re-create some standard system data before you begin importing / data loading. At a minimum: * You will likely need to re-create your authorities and vocabularies, so that you can once again save and import records into those. If you're using just the default set of authorities and vocabularies, rather than having created your own, you can now conveniently re-create these in every tenant via a script (http://issues.collectionspace.org/browse/CSPACE-5285). Or you can do the same thing by following the instructions under "Initializing default authorities and term lists" near the end of http://wiki.collectionspace.org/display/CSPACE25/Installing+2.5+on+Generic+Unix-like+or+Windows+Systems, while noting that you'll need to do this within your own tenant, by substituting your tenant's identifier for 'core' in those instructions. Aron P.S. There is an unresolved JIRA to make it convenient, via a call to the CollectionSpace services layer, to selectively delete all records of a particular record type: http://issues.collectionspace.org/browse/CSPACE-2948 > > > Thanks so much! > Sandra Tsai > > > _______________________________________________ > Talk mailing list > Talk@lists.collectionspace.org > http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org >
CH
Chris Hoffman
Thu, Oct 11, 2012 9:38 PM

Hi Sandra, in addition to Aron's great note, Glen Jackson on our team wrote a shell script that takes in a file of CSID's and deletes them.  Here's what the csdelete shell script looks like;

#!/bin/bash

SERVICE="cspace-services/collectionobjects"
CONTENT_TYPE="Content-Type: application/xml"
URL="http://localhost:8180"
USER="admin@core.collectionspace.org:Administrator"

flag=1
count=0

while read CSID
do
if [ $flag -eq 1 ]
then
echo "curl -X DELETE $URL/$SERVICE/$CSID -u "$USER" -H "$CONTENT_TYPE""
fi
count=$((count+1))
echo -n "${count}: $CSID"
curl -X DELETE $URL/$SERVICE/$CSID -u "$USER" -H "$CONTENT_TYPE"
echo $CSID >> deleted.list
echo " : Sleeping"
sleep 1
flag=0
done < todelete.list

In the SERVICE declaration you specify the kind of record you are deleting.  You put a list of CSIDs in a file called todelete.list and let the thing run!

This works if you are trying to delete specific records only.  If you are trying to start over altogether, Aron's second scenario is the right way to go.

Thanks,
Chris

On Oct 11, 2012, at 1:11 PM, Aron Roberts wrote:

On Thu, Oct 11, 2012 at 11:18 AM, Sandra Tsai sandrayun.tsai@gmail.com wrote:

We use CollectionSpace version 2.5. We have a question about how to erase
all records in CollectionSpace at one time.

First, if all you want to do is selectively delete records, and you
know - or can obtain - their unique identifiers (CSIDs) in your
system, there's a script here for doing exactly that:

http://wiki.collectionspace.org/display/CSPACE25/How+to+Import+Data

Alternately, could you be working in a setting, Sandra, where you're
testing data import / data loading on a non-production system, and
occasionally want to quickly wipe out all records and start completely
fresh?

If that's the case, and you truly want to delete all object,
procedural, authority/vocabulary term, and relationship records
throughout CollectionSpace, while retaining user and account
information, you could:

After doing so, you may also need to re-create some standard system
data before you begin importing / data loading.  At a minimum:

  • You will likely need to re-create your authorities and
    vocabularies, so that you can once again save and import records into
    those.  If you're using just the default set of authorities and
    vocabularies, rather than having created your own, you can now
    conveniently re-create these in every tenant via a script
    (http://issues.collectionspace.org/browse/CSPACE-5285).

Or you can do the same thing by following the instructions under
"Initializing default authorities and term lists" near the end of
http://wiki.collectionspace.org/display/CSPACE25/Installing+2.5+on+Generic+Unix-like+or+Windows+Systems,
while noting that you'll need to do this within your own tenant, by
substituting your tenant's identifier for 'core' in those
instructions.

Aron

P.S.  There is an unresolved JIRA to make it convenient, via a call to
the CollectionSpace services layer, to selectively delete all records
of a particular record type:

http://issues.collectionspace.org/browse/CSPACE-2948

Hi Sandra, in addition to Aron's great note, Glen Jackson on our team wrote a shell script that takes in a file of CSID's and deletes them. Here's what the csdelete shell script looks like; ---- #!/bin/bash SERVICE="cspace-services/collectionobjects" CONTENT_TYPE="Content-Type: application/xml" URL="http://localhost:8180" USER="admin@core.collectionspace.org:Administrator" flag=1 count=0 while read CSID do if [ $flag -eq 1 ] then echo "curl -X DELETE $URL/$SERVICE/$CSID -u \"$USER\" -H \"$CONTENT_TYPE\"" fi count=$((count+1)) echo -n "${count}: $CSID" curl -X DELETE $URL/$SERVICE/$CSID -u "$USER" -H "$CONTENT_TYPE" echo $CSID >> deleted.list echo " : Sleeping" sleep 1 flag=0 done < todelete.list ---- In the SERVICE declaration you specify the kind of record you are deleting. You put a list of CSIDs in a file called todelete.list and let the thing run! This works if you are trying to delete specific records only. If you are trying to start over altogether, Aron's second scenario is the right way to go. Thanks, Chris On Oct 11, 2012, at 1:11 PM, Aron Roberts wrote: > On Thu, Oct 11, 2012 at 11:18 AM, Sandra Tsai <sandrayun.tsai@gmail.com> wrote: >> We use CollectionSpace version 2.5. We have a question about how to erase >> all records in CollectionSpace at one time. > > First, if all you want to do is selectively delete records, and you > know - or can obtain - their unique identifiers (CSIDs) in your > system, there's a script here for doing exactly that: > > http://wiki.collectionspace.org/display/CSPACE25/How+to+Import+Data > > Alternately, could you be working in a setting, Sandra, where you're > testing data import / data loading on a *non-production* system, and > occasionally want to quickly wipe out all records and start completely > fresh? > > If that's the case, and you truly want to delete all object, > procedural, authority/vocabulary term, and relationship records > throughout CollectionSpace, while retaining user and account > information, you could: > > * Download the Services source code > (http://wiki.collectionspace.org/display/CSPACE25/How+to+check+out+the+Services+layer+source+code) > * Shut down the CollectionSpace servers > (http://wiki.collectionspace.org/display/CSPACE25/Shutting+Down+CollectionSpace+Servers) > * From the top level of the Services source code tree, type "ant > create_nuxeo_db". This will drop and re-create the 'nuxeo' database, > in which most of CollectionSpace's records reside. (WARNING WARNING > This will truly wipe the aforementioned data; these records will only > be capable of being restored from backup.) > * Restart the CollectionSpace servers > (http://wiki.collectionspace.org/display/CSPACE25/Starting+Up+CollectionSpace+Servers) > > After doing so, you may also need to re-create some standard system > data before you begin importing / data loading. At a minimum: > > * You will likely need to re-create your authorities and > vocabularies, so that you can once again save and import records into > those. If you're using just the default set of authorities and > vocabularies, rather than having created your own, you can now > conveniently re-create these in every tenant via a script > (http://issues.collectionspace.org/browse/CSPACE-5285). > > Or you can do the same thing by following the instructions under > "Initializing default authorities and term lists" near the end of > http://wiki.collectionspace.org/display/CSPACE25/Installing+2.5+on+Generic+Unix-like+or+Windows+Systems, > while noting that you'll need to do this within your own tenant, by > substituting your tenant's identifier for 'core' in those > instructions. > > Aron > > P.S. There is an unresolved JIRA to make it convenient, via a call to > the CollectionSpace services layer, to selectively delete all records > of a particular record type: > > http://issues.collectionspace.org/browse/CSPACE-2948 > >> >> >> Thanks so much! >> Sandra Tsai >> >> >> _______________________________________________ >> Talk mailing list >> Talk@lists.collectionspace.org >> http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org >> > > _______________________________________________ > Talk mailing list > Talk@lists.collectionspace.org > http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org