Last active
August 29, 2015 13:57
-
-
Save dcarroll/9610037 to your computer and use it in GitHub Desktop.
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
public class CreateMerchandiseData { | |
public static void ClearMerchandiseDataBatch() { | |
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' + | |
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)'; | |
CleanUpRecords c = new CleanUpRecords(query); | |
Database.executeBatch(c); | |
} | |
public static void GenerateMerchandiseData() { | |
// Create Warehouse if one does not exist | |
Warehouse__c w; | |
List<Warehouse__c> warehouse = [SELECT ID from Warehouse__c]; | |
if(warehouse.size() == 1 || warehouse.size() == 0) { | |
w = new Warehouse__c( | |
Name='Warehouse 1', | |
City__c='San Francisco', | |
Location__Latitude__s=37.7833, | |
Location__Longitude__s=122.4167); | |
insert w; | |
} else { | |
w = warehouse[0]; | |
} | |
Merchandise__c[] ml = new List<Merchandise__c>(); | |
for (Integer i=0;i<250;i++) { | |
Merchandise__c m = new Merchandise__c( | |
Name='Merchandise ' + i, | |
Price__c=2, | |
Quantity__c=100, | |
Warehouse__c = w.Id); | |
ml.add(m); | |
} | |
insert ml; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment