Unlocking an additional layer of safety to your iPhone is less difficult than you might suppose. With Two-Factor Time-Based One-Time Password (TOTP) authentication, you may bolster your device's protection and other website safety without relying on 1/3-party apps. Here's how you could set it up:
Show all project component (apex class, Visualforce page, customobjects etc )in Single Visualforce page
Here is sample code to view all project related components in Visualforce page (apex class, vf pages, permission set, public groups etc)
Class Code :-
public class Project_Components {
transient public List<displayListWrapper> displayList{get;set;}
transient public List<ApexClass> ClassList{get;set;}
transient public List<PageClassWrapper> pageClassList{get;set;}
transient public List<PermissionSet> permissionSetList{get;set;}
transient public List<Group> publicGroupList{get;set;}
transient public List<ProcessDefinition> processList {get;set;}
transient public List<ApexTrigger> triggerList {get;set;}
transient public List<ApexComponent> apexComponentList{get;set;}
transient public Map<String,String> objectNameVsLabelMap{get;set;}
transient public List<ObjectRelationshipWrapper> objectRelationList{get;set;}
public boolean isCollapsibleSection{get;set;}
public String collaspeAllButtonText{get;set;}
public Integer debugNum{get;set;}
public Integer size{get;set;}
public String debugstr{get;set;}
public List<String> objectList;
public Project_Components (){
collaspeAllButtonText='Group All';
toggleCollpsibleSection();
objectPermissionSetMappings();
getClassList();
PageVsClass();
objectRelationship();
apexComponents();
triggers();
processes();
}
public class newClass{
public String ObjectName{get;set;}
public String PermissionSets{get;set;}
public newClass(String n, String i){
this.ObjectName=n;
this.PermissionSets=i;
}
}
public void toggleCollpsibleSection(){
if(isCollapsibleSection==true){
isCollapsibleSection=false;
collaspeAllButtonText='Group All';
}
if(isCollapsibleSection==false){
isCollapsibleSection=true;
collaspeAllButtonText='Collapse All';
}
}
public class PermissionSetWrapper{
public String psName{get;set;}
public String psLabel{get;set;}
public PermissionSetWrapper(String name, String label, List<ObjectPermissions> oP){
this.psName=name;
this.psLabel=label;
}
}
public class displayListWrapper implements Comparable{
public String ObjectLabel{get;set;}
public String ObjectAPIName{get;set;}
public String ObjectSetupURL{get;set;}
public String ObjectPermissionSets{get;set;}
public displayListWrapper(String oname, String oapiname, String osetupurl){
this.ObjectLabel=oname;
this.ObjectAPIName=oapiname;
this.ObjectSetupURL=osetupurl;
this.ObjectPermissionSets=null;
}
public Integer compareTo(Object o){
Integer returnValue=0;
displayListWrapper obToCompareWith=(displayListWrapper)o;
if(this.ObjectLabel.equals(obToCompareWith.ObjectLabel))
returnValue=0;
if(this.ObjectLabel>obToCompareWith.ObjectLabel)
returnValue=1;
if(this.ObjectLabel<obToCompareWith.ObjectLabel)
returnValue=-1;
return returnValue;
}
}
public class PageClassWrapper{
public Id PageId{get;set;}
public String PageName{get;set;}
public String stdCtrlName{get;set;}
public String ctrlName{get;set;}
public String extName{get;set;}
public PageClassWrapper(Id i, String a, String b, String c, String d){
PageId=i;
PageName=a;
stdCtrlName=b;
ctrlName=c;
extName=d;
}
}
public class ObjectRelationshipWrapper{
public String objectName{get;set;}
public List<FieldDetailWrapper> objectRelationList{get;set;}
public ObjectRelationshipWrapper(String obName, List<FieldDetailWrapper> fList){
objectName=obName;
objectRelationList=fList;
}
}
public class FieldDetailWrapper{
public String relatedObjectName{get;set;}
public String relatedFieldName{get;set;}
public String lookupOrMD{get;set;}
public String primaryOrSecondaryMD{get;set;}
public String relationshipName{get;set;}
public FieldDetailWrapper(){
relatedObjectName=null;
relatedFieldName=null;
lookupOrMD=null;
primaryOrSecondaryMD=null;
relationshipName=null;
}
public FieldDetailWrapper(String robName, String rFldName, String rLUOrMD, String rpOS, String rName){
relatedObjectName=robName;
relatedFieldName=rFldName;
lookupOrMD=rLUOrMD;
primaryOrSecondaryMD=rpOS;
relationshipName=rName;
}
}
public void objectPermissionSetMappings(){
Map<String, String> permissionSetDetails;
List<String> oNameList;
Map<String, Schema.SObjectType> allObjects = Schema.getGlobalDescribe();
objectList=new List<String>();
displayList=new List<displayListWrapper>();
List<PermissionSet> pSet=[SELECT Id, Label FROM PermissionSet WHERE Label like '% your project namespace %' ORDER BY Name ASC];
Map<Id,String> pMap=new Map<Id,String>();
for(PermissionSet ps: pSet)
pMap.put(ps.Id,ps.Label);
permissionSetList=pSet;
//Iterate through the list of objects and filter Objects and add the API name to objectList
for(String sIterator : allObjects.keySet()){
if(sIterator.startsWithIgnoreCase('your project namespace')&&sIterator.containsIgnoreCase('__c'))
objectList.add(sIterator);
}
//Describe the objects in 'objectList', save API name in 'oNameList' to be used as Argument in SOQL to find the URL
Schema.DescribeSObjectResult[] oProp=Schema.describeSObjects(objectList);
oNameList=new List<String>();
for(Schema.DescribeSObjectResult it: oProp){
oNameList.add(it.getName().replace('__c',''));
}
//Get Setup Edit URL for Object
List<EntityDefinition> objectSetupURLList=[SELECT DeveloperName,DurableId FROM EntityDefinition WHERE DeveloperName IN :oNameList];
Map<String,String> objectSetupURLMap=new Map<String,String>();
for(EntityDefinition x: objectSetupURLList){
objectSetupURLMap.put(x.DeveloperName,x.DurableId);
}
//add the data in displayList
for(Schema.DescribeSObjectResult it: oProp){
displayList.add(new displayListWrapper(it.getLabel(),it.getName(),objectSetupURLMap.get(it.getName().replace('__c',''))));
}
displayList.sort();
//Pick the API Names of objects
List<String> obAPIList=new List<String>();
for(displayListWrapper dIterator: displayList)
obAPIList.add(dIterator.ObjectAPIName);
//Run query to bring ParentId from ObjectPermissions
List<ObjectPermissions> obPerms=[SELECT ParentId,SobjectType FROM ObjectPermissions WHERE SobjectType IN :obAPIList ORDER BY SobjectType ASC];
Map<String,List<Id>> permMap=new Map<String,List<Id>>();
permissionSetDetails=new Map<String,String>();
//Add data to a map where Key is objectAPI name and Value is List of permission sets
for(String oname: obAPIList){
List<Id> temp=new List<Id>();
String j='';
for(ObjectPermissions osd: obPerms){
j='';
if(osd.SobjectType.equals(oname)){
temp.add(osd.ParentId);
}
Integer i=0;
for(Id b: temp){
if(i==0||i==(temp.size())){
if(pMap.get(b)!=null)
j=pMap.get(b);
}
else{
if(pMap.get(b)!=null)
j=pMap.get(b)+', '+j;
}
i++;
}
}
permissionSetDetails.put(oname,j);
}
for(displayListWrapper dIterator: displayList)
dIterator.ObjectPermissionSets=permissionSetDetails.get(dIterator.ObjectAPIName);
}
public void getClassList(){
ClassList=[SELECT Name FROM ApexClass WHERE Name like '% your project namespace %'];
}
public void viewObjectFields(){
String objectProp=ApexPages.currentPage().getParameters().get('objectProp');
SObjectType objectType = Schema.getGlobalDescribe().get(objectProp);
Map<String,Schema.SObjectField> mfields = objectType.getDescribe().fields.getMap();
}
public void apexComponents(){
apexComponentList=[SELECT Id,Name FROM ApexComponent WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void publicGroups(){
publicGroupList=[SELECT Id, Name FROM Group WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void workflows(){
// workflowlist=[SELECT Id,Name FROM workflow WHERE Name LIKE 'your project namespace%' ORDER BY Name ASC];
}
public void processes(){
processList=[SELECT Id,Name FROM ProcessDefinition WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void triggers(){
triggerList=[SELECT Id,Name FROM ApexTrigger WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void PageVsClass(){
String stdCtrlName='';
String ctrlName='';
String extName='';
pageClassList=new List<PageClassWrapper>();
List<ApexPage> PageList=[SELECT Name, Markup FROM ApexPage WHERE Name like 'your project namespace%' ORDER BY Name ASC];
for(ApexPage aPage: PageList){
Integer intvariable, startPoint, endPoint;
String stringVariable=aPage.Markup;
if(stringVariable.contains('standardController')){
intvariable=stringVariable.indexOf('standardController=\"')+('standardController=\"'.length());
startPoint=stringVariable.indexOf('standardController=\"')+('standardController=\"'.length());
endPoint=stringVariable.indexOf('"',intvariable);
stdCtrlName=stringVariable.substring(startPoint,endPoint);
}
else
stdCtrlName='--';
if(stringVariable.contains('extensions')){
intVariable=stringVariable.indexOf('extensions=\"')+('extensions=\"'.length());
startPoint=stringVariable.indexOf('extensions=\"')+('extensions=\"'.length());
endPoint=stringVariable.indexOf('"',intvariable);
extName=stringVariable.substring(startPoint,endPoint);
if(extName.contains(',')){
String inputStr=extName;
extName='';
String[] extArray=inputStr.split(',');
for(Integer k=0;k<extArray.size();k++){
if(k!=extArray.size()-1)
extName+=extArray[k].trim()+', ';
else
extName+=extArray[k].trim();
}
}
}
else
extName='--';
if(stringVariable.contains('controller')){
intvariable=stringVariable.indexOf('controller=\"')+('controller=\"'.length());
startPoint=stringVariable.indexOf('controller=\"')+('controller=\"'.length());
endPoint=stringVariable.indexOf('"',intvariable);
ctrlName=stringVariable.substring(startPoint,endPoint);
}
else
ctrlName='--';
pageClassList.add(new PageClassWrapper(aPage.Id,aPage.Name,stdCtrlName,ctrlName,extName));
}
}
public void objectRelationship(){
objectNameVsLabelMap=new Map<String,String>();
Map<String, Schema.SObjectType> allObjectMap= Schema.getGlobalDescribe();
List<String> ObjectList=new List<String>();
//added by VT
Schema.DescribeSObjectResult[] descResult = Schema.describeSObjects(objectList);
for(Schema.DescribeSObjectResult i1: descResult){
String obName=(String)i1.getName();
if(obName.contains(' your project namespace ')&&(!obName.contains('History')&&!obName.contains('Share'))){
ObjectList.add(i1.getName());
objectNameVsLabelMap.put(i1.getName(),i1.getLabel());
}
}
List<Schema.DescribeSObjectResult> ObjectDescribeResult=Schema.describeSObjects(ObjectList);
List<FieldDetailWrapper> fieldList;
objectRelationList=new List<ObjectRelationshipWrapper>();
for(Schema.DescribeSObjectResult i2: ObjectDescribeResult)
{
fieldList=new List<FieldDetailWrapper>();
Map<String, Schema.SObjectField> ObjectFieldsMap=i2.fields.getMap();
for(Schema.SObjectField s5: ObjectFieldsMap.values()){
Schema.DescribeFieldResult ob3=s5.getDescribe();
if(ob3.getRelationshipName()!=null&&ob3.getSobjectField().getDescribe().getName()!=null){
FieldDetailWrapper fdwObj=new FieldDetailWrapper();
fdwObj.relatedObjectName=objectNameVsLabelMap.get(ob3.getSobjectField().getDescribe().getName());
fdwObj.relatedFieldName=ob3.getLabel();
fdwObj.lookupOrMD=ob3.getRelationshipOrder()==null?'Look-up':'Master-Detail';
if(ob3.getRelationshipOrder()!=null){
if(ob3.getRelationshipOrder()==1)
fdwObj.primaryOrSecondaryMD='Primary';
else
fdwObj.primaryOrSecondaryMD='Secondary';
}
fdwObj.relationshipName=ob3.getRelationshipName();
fieldList.add(fdwObj);
}
}
ObjectRelationshipWrapper orwObj=new ObjectRelationshipWrapper(i2.getLabel(),fieldList);
if(orwObj.objectRelationList.size()>0)
objectRelationList.add(orwObj);
}
}
}
Visualforce Page:-
<apex:page controller="Project_Components" showHeader="false" lightningStylesheets="true" tabStyle="account">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
<apex:slds />
<div class="slds-scope">
<div class="slds-container--center slds-box slds-container--x-large slds-theme_shade slds-theme_alert-texture container-fluid">
<div class="slds-page-header">
<div class="slds-page-header__row">
<div class="slds-page-header__col-title">
<div class="slds-media">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon_container_circle slds-icon-action-description" title="Description of icon when needed">
<svg class="slds-icon" aria-hidden="true">
<use xlink:href="/apexpages/slds/latest/assets/icons/action-sprite/svg/symbols.svg#description"></use>
</svg>
<span class="slds-assistive-text">Description of icon when needed</span>
</span>
</div>
<div class="slds-media__body">
<div class="slds-page-header__name">
<div class="slds-page-header__name-title">
<h1>
<span style="margin: 8px;" class="slds-page-header__title slds-truncate" title="">Component</span>
</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div> <br/>
<apex:form title="Component">
<apex:actionFunction name="viewObjectFields" action="{!viewObjectFields}" reRender="fieldTable">
<apex:param id="param1" name="objectProp" value=""/>
</apex:actionFunction>
<apex:pageBlock tabStyle="Account" title="Permission Set - ({!permissionSetList.size})" mode="view" >
<apex:pageBlockSection collapsible="true" columns="3" showHeader="false" title="Details" >
<apex:repeat value="{!permissionSetList}" var="pIterator">
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!pIterator.Id}">{!pIterator.Label}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Object Label, API Names and Permission Sets" tabStyle="opportunity">
<apex:variable value="{!1}" var="counter"/>
<apex:pageBlockTable value="{!displayList}" var="objectVar" id="objectTable" >
<apex:column headerValue="S No." >
{!counter}
<apex:variable value="{!counter+1}" var="counter"/>
</apex:column>
<apex:column headerValue="Object Label">
<apex:outputLink target="_blank" value="/{!objectVar.ObjectSetupURL}">{!objectVar.ObjectLabel}</apex:outputLink>
</apex:column>
<apex:column value="{!objectVar.ObjectAPIName}" headerValue="Object API Name"/>
<apex:column value="{!objectVar.ObjectPermissionSets}" headerValue="Permission Sets"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Pages - ({!pageClassList.size})" tabStyle="Case">
<apex:variable value="{!1}" var="counter"/>
<apex:pageBlockTable value="{!pageClassList}" var="pageIterator" styleClass="pageTable">
<apex:column headerValue="S No." >
{!counter}
<apex:variable value="{!counter+1}" var="counter"/>
</apex:column>
<apex:column headerValue="Page Name">
<apex:outputLink target="_blank" value="/{!pageIterator.PageId}">{!pageIterator.PageName}</apex:outputLink>
</apex:column>
<apex:column value="{!pageIterator.stdCtrlName}" headerValue="Standard Controller Name"/>
<apex:column value="{!pageIterator.ctrlName}" headerValue="Controller Name"/>
<apex:column value="{!pageIterator.extName}" headerValue="Extensions"/>
</apex:pageBlockTable>
</apex:pageblock>
<apex:pageBlock title="Apex Classes - ({!ClassList.size})" tabStyle="Lead">
<apex:pageBlockSection columns="3">
<apex:repeat value="{!ClassList}" var="classIterator" >
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!classIterator.Id}">{!classIterator.Name}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Apex Components - ({!apexComponentList.size})" tabStyle="Account">
<apex:pageBlockSection collapsible="false" rendered="true" columns="3" >
<apex:repeat value="{!apexComponentList}" var="aCompIterator">
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!aCompIterator.Id}">{!aCompIterator.Name}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Triggers - ({!triggerList.size})" tabStyle="Contact">
<apex:pageBlockSection collapsible="false" rendered="true" columns="3" >
<apex:repeat value="{!triggerList}" var="trigIterator">
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!trigIterator.Id}">{!trigIterator.Name}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageblock title="Object Relation - ({!objectRelationList.size})" tabstyle="Opportunity">
<apex:pageBlockSection collapsible="false" rendered="true" columns="1">
<apex:pageBlockTable value="{!objectRelationList}" var="orlIterator" styleClass="pageTable">
<apex:column headerValue="Object Name" value="{!orlIterator.objectName}"/>
<apex:column headerValue="Related Object Information">
<apex:pageBlockTable value="{!orlIterator.objectRelationList}" var="orlIter">
<apex:column value="{!orlIter.relatedObjectName}" headerValue="Related Object Name"/>
<apex:column value="{!orlIter.relatedFieldName}" headerValue="Related Field Name"/>
<apex:column value="{!orlIter.lookupOrMD}" headerValue="Relation Type"/>
<apex:column value="{!orlIter.primaryOrSecondaryMD}" headerValue="Relation Category"/>
<apex:column value="{!orlIter.relationshipName}" headerValue="Relation Name"/>
<br/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</div>
</div>
</html>
</apex:page>
transient public List<displayListWrapper> displayList{get;set;}
transient public List<ApexClass> ClassList{get;set;}
transient public List<PageClassWrapper> pageClassList{get;set;}
transient public List<PermissionSet> permissionSetList{get;set;}
transient public List<Group> publicGroupList{get;set;}
transient public List<ProcessDefinition> processList {get;set;}
transient public List<ApexTrigger> triggerList {get;set;}
transient public List<ApexComponent> apexComponentList{get;set;}
transient public Map<String,String> objectNameVsLabelMap{get;set;}
transient public List<ObjectRelationshipWrapper> objectRelationList{get;set;}
public boolean isCollapsibleSection{get;set;}
public String collaspeAllButtonText{get;set;}
public Integer debugNum{get;set;}
public Integer size{get;set;}
public String debugstr{get;set;}
public List<String> objectList;
public Project_Components (){
collaspeAllButtonText='Group All';
toggleCollpsibleSection();
objectPermissionSetMappings();
getClassList();
PageVsClass();
objectRelationship();
apexComponents();
triggers();
processes();
}
public class newClass{
public String ObjectName{get;set;}
public String PermissionSets{get;set;}
public newClass(String n, String i){
this.ObjectName=n;
this.PermissionSets=i;
}
}
public void toggleCollpsibleSection(){
if(isCollapsibleSection==true){
isCollapsibleSection=false;
collaspeAllButtonText='Group All';
}
if(isCollapsibleSection==false){
isCollapsibleSection=true;
collaspeAllButtonText='Collapse All';
}
}
public class PermissionSetWrapper{
public String psName{get;set;}
public String psLabel{get;set;}
public PermissionSetWrapper(String name, String label, List<ObjectPermissions> oP){
this.psName=name;
this.psLabel=label;
}
}
public class displayListWrapper implements Comparable{
public String ObjectLabel{get;set;}
public String ObjectAPIName{get;set;}
public String ObjectSetupURL{get;set;}
public String ObjectPermissionSets{get;set;}
public displayListWrapper(String oname, String oapiname, String osetupurl){
this.ObjectLabel=oname;
this.ObjectAPIName=oapiname;
this.ObjectSetupURL=osetupurl;
this.ObjectPermissionSets=null;
}
public Integer compareTo(Object o){
Integer returnValue=0;
displayListWrapper obToCompareWith=(displayListWrapper)o;
if(this.ObjectLabel.equals(obToCompareWith.ObjectLabel))
returnValue=0;
if(this.ObjectLabel>obToCompareWith.ObjectLabel)
returnValue=1;
if(this.ObjectLabel<obToCompareWith.ObjectLabel)
returnValue=-1;
return returnValue;
}
}
public class PageClassWrapper{
public Id PageId{get;set;}
public String PageName{get;set;}
public String stdCtrlName{get;set;}
public String ctrlName{get;set;}
public String extName{get;set;}
public PageClassWrapper(Id i, String a, String b, String c, String d){
PageId=i;
PageName=a;
stdCtrlName=b;
ctrlName=c;
extName=d;
}
}
public class ObjectRelationshipWrapper{
public String objectName{get;set;}
public List<FieldDetailWrapper> objectRelationList{get;set;}
public ObjectRelationshipWrapper(String obName, List<FieldDetailWrapper> fList){
objectName=obName;
objectRelationList=fList;
}
}
public class FieldDetailWrapper{
public String relatedObjectName{get;set;}
public String relatedFieldName{get;set;}
public String lookupOrMD{get;set;}
public String primaryOrSecondaryMD{get;set;}
public String relationshipName{get;set;}
public FieldDetailWrapper(){
relatedObjectName=null;
relatedFieldName=null;
lookupOrMD=null;
primaryOrSecondaryMD=null;
relationshipName=null;
}
public FieldDetailWrapper(String robName, String rFldName, String rLUOrMD, String rpOS, String rName){
relatedObjectName=robName;
relatedFieldName=rFldName;
lookupOrMD=rLUOrMD;
primaryOrSecondaryMD=rpOS;
relationshipName=rName;
}
}
public void objectPermissionSetMappings(){
Map<String, String> permissionSetDetails;
List<String> oNameList;
Map<String, Schema.SObjectType> allObjects = Schema.getGlobalDescribe();
objectList=new List<String>();
displayList=new List<displayListWrapper>();
List<PermissionSet> pSet=[SELECT Id, Label FROM PermissionSet WHERE Label like '% your project namespace %' ORDER BY Name ASC];
Map<Id,String> pMap=new Map<Id,String>();
for(PermissionSet ps: pSet)
pMap.put(ps.Id,ps.Label);
permissionSetList=pSet;
//Iterate through the list of objects and filter Objects and add the API name to objectList
for(String sIterator : allObjects.keySet()){
if(sIterator.startsWithIgnoreCase('your project namespace')&&sIterator.containsIgnoreCase('__c'))
objectList.add(sIterator);
}
//Describe the objects in 'objectList', save API name in 'oNameList' to be used as Argument in SOQL to find the URL
Schema.DescribeSObjectResult[] oProp=Schema.describeSObjects(objectList);
oNameList=new List<String>();
for(Schema.DescribeSObjectResult it: oProp){
oNameList.add(it.getName().replace('__c',''));
}
//Get Setup Edit URL for Object
List<EntityDefinition> objectSetupURLList=[SELECT DeveloperName,DurableId FROM EntityDefinition WHERE DeveloperName IN :oNameList];
Map<String,String> objectSetupURLMap=new Map<String,String>();
for(EntityDefinition x: objectSetupURLList){
objectSetupURLMap.put(x.DeveloperName,x.DurableId);
}
//add the data in displayList
for(Schema.DescribeSObjectResult it: oProp){
displayList.add(new displayListWrapper(it.getLabel(),it.getName(),objectSetupURLMap.get(it.getName().replace('__c',''))));
}
displayList.sort();
//Pick the API Names of objects
List<String> obAPIList=new List<String>();
for(displayListWrapper dIterator: displayList)
obAPIList.add(dIterator.ObjectAPIName);
//Run query to bring ParentId from ObjectPermissions
List<ObjectPermissions> obPerms=[SELECT ParentId,SobjectType FROM ObjectPermissions WHERE SobjectType IN :obAPIList ORDER BY SobjectType ASC];
Map<String,List<Id>> permMap=new Map<String,List<Id>>();
permissionSetDetails=new Map<String,String>();
//Add data to a map where Key is objectAPI name and Value is List of permission sets
for(String oname: obAPIList){
List<Id> temp=new List<Id>();
String j='';
for(ObjectPermissions osd: obPerms){
j='';
if(osd.SobjectType.equals(oname)){
temp.add(osd.ParentId);
}
Integer i=0;
for(Id b: temp){
if(i==0||i==(temp.size())){
if(pMap.get(b)!=null)
j=pMap.get(b);
}
else{
if(pMap.get(b)!=null)
j=pMap.get(b)+', '+j;
}
i++;
}
}
permissionSetDetails.put(oname,j);
}
for(displayListWrapper dIterator: displayList)
dIterator.ObjectPermissionSets=permissionSetDetails.get(dIterator.ObjectAPIName);
}
public void getClassList(){
ClassList=[SELECT Name FROM ApexClass WHERE Name like '% your project namespace %'];
}
public void viewObjectFields(){
String objectProp=ApexPages.currentPage().getParameters().get('objectProp');
SObjectType objectType = Schema.getGlobalDescribe().get(objectProp);
Map<String,Schema.SObjectField> mfields = objectType.getDescribe().fields.getMap();
}
public void apexComponents(){
apexComponentList=[SELECT Id,Name FROM ApexComponent WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void publicGroups(){
publicGroupList=[SELECT Id, Name FROM Group WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void workflows(){
// workflowlist=[SELECT Id,Name FROM workflow WHERE Name LIKE 'your project namespace%' ORDER BY Name ASC];
}
public void processes(){
processList=[SELECT Id,Name FROM ProcessDefinition WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void triggers(){
triggerList=[SELECT Id,Name FROM ApexTrigger WHERE Name LIKE 'your project namespace %' ORDER BY Name ASC];
}
public void PageVsClass(){
String stdCtrlName='';
String ctrlName='';
String extName='';
pageClassList=new List<PageClassWrapper>();
List<ApexPage> PageList=[SELECT Name, Markup FROM ApexPage WHERE Name like 'your project namespace%' ORDER BY Name ASC];
for(ApexPage aPage: PageList){
Integer intvariable, startPoint, endPoint;
String stringVariable=aPage.Markup;
if(stringVariable.contains('standardController')){
intvariable=stringVariable.indexOf('standardController=\"')+('standardController=\"'.length());
startPoint=stringVariable.indexOf('standardController=\"')+('standardController=\"'.length());
endPoint=stringVariable.indexOf('"',intvariable);
stdCtrlName=stringVariable.substring(startPoint,endPoint);
}
else
stdCtrlName='--';
if(stringVariable.contains('extensions')){
intVariable=stringVariable.indexOf('extensions=\"')+('extensions=\"'.length());
startPoint=stringVariable.indexOf('extensions=\"')+('extensions=\"'.length());
endPoint=stringVariable.indexOf('"',intvariable);
extName=stringVariable.substring(startPoint,endPoint);
if(extName.contains(',')){
String inputStr=extName;
extName='';
String[] extArray=inputStr.split(',');
for(Integer k=0;k<extArray.size();k++){
if(k!=extArray.size()-1)
extName+=extArray[k].trim()+', ';
else
extName+=extArray[k].trim();
}
}
}
else
extName='--';
if(stringVariable.contains('controller')){
intvariable=stringVariable.indexOf('controller=\"')+('controller=\"'.length());
startPoint=stringVariable.indexOf('controller=\"')+('controller=\"'.length());
endPoint=stringVariable.indexOf('"',intvariable);
ctrlName=stringVariable.substring(startPoint,endPoint);
}
else
ctrlName='--';
pageClassList.add(new PageClassWrapper(aPage.Id,aPage.Name,stdCtrlName,ctrlName,extName));
}
}
public void objectRelationship(){
objectNameVsLabelMap=new Map<String,String>();
Map<String, Schema.SObjectType> allObjectMap= Schema.getGlobalDescribe();
List<String> ObjectList=new List<String>();
//added by VT
Schema.DescribeSObjectResult[] descResult = Schema.describeSObjects(objectList);
for(Schema.DescribeSObjectResult i1: descResult){
String obName=(String)i1.getName();
if(obName.contains(' your project namespace ')&&(!obName.contains('History')&&!obName.contains('Share'))){
ObjectList.add(i1.getName());
objectNameVsLabelMap.put(i1.getName(),i1.getLabel());
}
}
List<Schema.DescribeSObjectResult> ObjectDescribeResult=Schema.describeSObjects(ObjectList);
List<FieldDetailWrapper> fieldList;
objectRelationList=new List<ObjectRelationshipWrapper>();
for(Schema.DescribeSObjectResult i2: ObjectDescribeResult)
{
fieldList=new List<FieldDetailWrapper>();
Map<String, Schema.SObjectField> ObjectFieldsMap=i2.fields.getMap();
for(Schema.SObjectField s5: ObjectFieldsMap.values()){
Schema.DescribeFieldResult ob3=s5.getDescribe();
if(ob3.getRelationshipName()!=null&&ob3.getSobjectField().getDescribe().getName()!=null){
FieldDetailWrapper fdwObj=new FieldDetailWrapper();
fdwObj.relatedObjectName=objectNameVsLabelMap.get(ob3.getSobjectField().getDescribe().getName());
fdwObj.relatedFieldName=ob3.getLabel();
fdwObj.lookupOrMD=ob3.getRelationshipOrder()==null?'Look-up':'Master-Detail';
if(ob3.getRelationshipOrder()!=null){
if(ob3.getRelationshipOrder()==1)
fdwObj.primaryOrSecondaryMD='Primary';
else
fdwObj.primaryOrSecondaryMD='Secondary';
}
fdwObj.relationshipName=ob3.getRelationshipName();
fieldList.add(fdwObj);
}
}
ObjectRelationshipWrapper orwObj=new ObjectRelationshipWrapper(i2.getLabel(),fieldList);
if(orwObj.objectRelationList.size()>0)
objectRelationList.add(orwObj);
}
}
}
Visualforce Page:-
<apex:page controller="Project_Components" showHeader="false" lightningStylesheets="true" tabStyle="account">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
<apex:slds />
<div class="slds-scope">
<div class="slds-container--center slds-box slds-container--x-large slds-theme_shade slds-theme_alert-texture container-fluid">
<div class="slds-page-header">
<div class="slds-page-header__row">
<div class="slds-page-header__col-title">
<div class="slds-media">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon_container_circle slds-icon-action-description" title="Description of icon when needed">
<svg class="slds-icon" aria-hidden="true">
<use xlink:href="/apexpages/slds/latest/assets/icons/action-sprite/svg/symbols.svg#description"></use>
</svg>
<span class="slds-assistive-text">Description of icon when needed</span>
</span>
</div>
<div class="slds-media__body">
<div class="slds-page-header__name">
<div class="slds-page-header__name-title">
<h1>
<span style="margin: 8px;" class="slds-page-header__title slds-truncate" title="">Component</span>
</h1>
</div>
</div>
</div>
</div>
</div>
</div>
</div> <br/>
<apex:form title="Component">
<apex:actionFunction name="viewObjectFields" action="{!viewObjectFields}" reRender="fieldTable">
<apex:param id="param1" name="objectProp" value=""/>
</apex:actionFunction>
<apex:pageBlock tabStyle="Account" title="Permission Set - ({!permissionSetList.size})" mode="view" >
<apex:pageBlockSection collapsible="true" columns="3" showHeader="false" title="Details" >
<apex:repeat value="{!permissionSetList}" var="pIterator">
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!pIterator.Id}">{!pIterator.Label}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Object Label, API Names and Permission Sets" tabStyle="opportunity">
<apex:variable value="{!1}" var="counter"/>
<apex:pageBlockTable value="{!displayList}" var="objectVar" id="objectTable" >
<apex:column headerValue="S No." >
{!counter}
<apex:variable value="{!counter+1}" var="counter"/>
</apex:column>
<apex:column headerValue="Object Label">
<apex:outputLink target="_blank" value="/{!objectVar.ObjectSetupURL}">{!objectVar.ObjectLabel}</apex:outputLink>
</apex:column>
<apex:column value="{!objectVar.ObjectAPIName}" headerValue="Object API Name"/>
<apex:column value="{!objectVar.ObjectPermissionSets}" headerValue="Permission Sets"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Pages - ({!pageClassList.size})" tabStyle="Case">
<apex:variable value="{!1}" var="counter"/>
<apex:pageBlockTable value="{!pageClassList}" var="pageIterator" styleClass="pageTable">
<apex:column headerValue="S No." >
{!counter}
<apex:variable value="{!counter+1}" var="counter"/>
</apex:column>
<apex:column headerValue="Page Name">
<apex:outputLink target="_blank" value="/{!pageIterator.PageId}">{!pageIterator.PageName}</apex:outputLink>
</apex:column>
<apex:column value="{!pageIterator.stdCtrlName}" headerValue="Standard Controller Name"/>
<apex:column value="{!pageIterator.ctrlName}" headerValue="Controller Name"/>
<apex:column value="{!pageIterator.extName}" headerValue="Extensions"/>
</apex:pageBlockTable>
</apex:pageblock>
<apex:pageBlock title="Apex Classes - ({!ClassList.size})" tabStyle="Lead">
<apex:pageBlockSection columns="3">
<apex:repeat value="{!ClassList}" var="classIterator" >
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!classIterator.Id}">{!classIterator.Name}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Apex Components - ({!apexComponentList.size})" tabStyle="Account">
<apex:pageBlockSection collapsible="false" rendered="true" columns="3" >
<apex:repeat value="{!apexComponentList}" var="aCompIterator">
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!aCompIterator.Id}">{!aCompIterator.Name}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Triggers - ({!triggerList.size})" tabStyle="Contact">
<apex:pageBlockSection collapsible="false" rendered="true" columns="3" >
<apex:repeat value="{!triggerList}" var="trigIterator">
<apex:pageBlockSectionItem >
<apex:outputLink target="_blank" value="/{!trigIterator.Id}">{!trigIterator.Name}</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageblock title="Object Relation - ({!objectRelationList.size})" tabstyle="Opportunity">
<apex:pageBlockSection collapsible="false" rendered="true" columns="1">
<apex:pageBlockTable value="{!objectRelationList}" var="orlIterator" styleClass="pageTable">
<apex:column headerValue="Object Name" value="{!orlIterator.objectName}"/>
<apex:column headerValue="Related Object Information">
<apex:pageBlockTable value="{!orlIterator.objectRelationList}" var="orlIter">
<apex:column value="{!orlIter.relatedObjectName}" headerValue="Related Object Name"/>
<apex:column value="{!orlIter.relatedFieldName}" headerValue="Related Field Name"/>
<apex:column value="{!orlIter.lookupOrMD}" headerValue="Relation Type"/>
<apex:column value="{!orlIter.primaryOrSecondaryMD}" headerValue="Relation Category"/>
<apex:column value="{!orlIter.relationshipName}" headerValue="Relation Name"/>
<br/>
</apex:pageBlockTable>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</div>
</div>
</html>
</apex:page>