package
juddiv3admin.juddiv3;
import
java.util.ArrayList;
import
java.util.List;
import
juddiv3admin.gui.GUI;
import
org.apache.juddi.api_v3.*;
import
org.uddi.api_v3.*;
public
class
QueryBuilder
{
//--------------------------- Business ---------------------------
public
static
FindBusiness GetFindBusinessAll()
{
Name name = new
Name();
name.setValue("%"
);
FindQualifiers qualifiers = new
FindQualifiers();
qualifiers.getFindQualifier().add(FindQualifiersAbbreviations.APPROXIMATE_MATCH);
FindBusiness findBusiness = new
FindBusiness();
findBusiness.getName().add(name);
findBusiness.setFindQualifiers(qualifiers);
return
findBusiness;
}
public
static
SaveBusiness GetSaveBusiness(BusinessEntity businessEntity, AuthToken authToken) throws
Exception
{
if
(businessEntity == null
)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
SaveBusiness sb = new
SaveBusiness();
sb.getBusinessEntity().add(businessEntity);
sb.setAuthInfo(authToken.getAuthInfo());
return
sb;
}
public
static
DeleteBusiness GetDeleteBusiness(BusinessEntity businessEntity, AuthToken authToken) throws
Exception
{
if
(businessEntity == null
)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
DeleteBusiness db = new
DeleteBusiness();
db.setAuthInfo(authToken.getAuthInfo());
db.getBusinessKey().add(businessEntity.getBusinessKey());
return
db;
}
public
static
DeleteBusiness GetDeleteBusiness(BusinessDetail businessDetail, AuthToken authToken) throws
Exception
{
if
(businessDetail == null
)
{
return
null
;
}
if
(businessDetail.getBusinessEntity() == null
)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
DeleteBusiness db = new
DeleteBusiness();
db.setAuthInfo(authToken.getAuthInfo());
for
(BusinessEntity businessEntity : businessDetail.getBusinessEntity())
{
db.getBusinessKey().add(businessEntity.getBusinessKey());
}
return
db;
}
//--------------------------- end of Business ---------------------------
//--------------------------- Service ---------------------------
public
static
FindService GetFindServiceAll()
{
Name name = new
Name();
name.setValue("%"
);
FindQualifiers qualifiers = new
FindQualifiers();
qualifiers.getFindQualifier().add(FindQualifiersAbbreviations.APPROXIMATE_MATCH);
FindService findService = new
FindService();
findService.getName().add(name);
findService.setFindQualifiers(qualifiers);
return
findService;
}
public
static
DeleteService GetDeleteService(BusinessService businessService, AuthToken authToken) throws
Exception
{
if
(businessService == null
)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
final
DeleteService ds = new
DeleteService();
ds.setAuthInfo(authToken.getAuthInfo());
ds.getServiceKey().add(businessService.getServiceKey());
return
ds;
}
public
static
DeleteService GetDeleteService(ServiceDetail serviceDetail, AuthToken authToken) throws
Exception
{
if
(serviceDetail == null
)
{
return
null
;
}
if
(serviceDetail.getBusinessService() == null
)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
DeleteService ds = new
DeleteService();
ds.setAuthInfo(authToken.getAuthInfo());
for
(BusinessService businessService : serviceDetail.getBusinessService())
{
ds.getServiceKey().add(businessService.getServiceKey());
}
return
ds;
}
public
static
SaveService GetSaveService(BusinessService businessService, AuthToken authToken) throws
Exception
{
if
(businessService == null
)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
SaveService ss = new
SaveService();
ss.setAuthInfo(authToken.getAuthInfo());
ss.getBusinessService().add(businessService);
return
ss;
}
public
static
SaveService GetSaveService(List<BusinessService> businessServiceList, AuthToken authToken) throws
Exception
{
if
(businessServiceList == null
)
{
return
null
;
}
if
(businessServiceList.size() <= 0)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
SaveService ss = new
SaveService();
ss.setAuthInfo(authToken.getAuthInfo());
for
(BusinessService businessService : businessServiceList)
{
ss.getBusinessService().add(businessService);
}
return
ss;
}
//--------------------------- end of Service---------------------------
//--------------------------- Publisher ---------------------------
public
static
GetAllPublisherDetail GetAllPublisherDetail(AuthToken authToken) throws
Exception
{
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
GetAllPublisherDetail gapd = new
GetAllPublisherDetail();
gapd.setAuthInfo(authToken.getAuthInfo());
return
gapd;
}
public
static
SavePublisher GetSavePublisher(List<Publisher> listPublisher, AuthToken authToken) throws
Exception
{
if
(listPublisher == null
)
{
return
null
;
}
if
(listPublisher.size() <= 0)
{
return
null
;
}
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
SavePublisher sp = new
SavePublisher();
sp.setAuthInfo(authToken.getAuthInfo());
sp.getPublisher().addAll(listPublisher);
return
sp;
}
public
static
SavePublisher GetSavePublisher(Publisher publisher, AuthToken authToken) throws
Exception
{
List listPublisher = new
ArrayList<Publisher>();
listPublisher.add(publisher);
return
GetSavePublisher(listPublisher, authToken);
}
public
static
DeletePublisher GetDeletePublisher(List<String> listPublisherId, AuthToken authToken) throws
Exception
{
if
(authToken == null
)
{
throw
GUI.GetExceptionNoAuthorization();
}
DeletePublisher dp = new
DeletePublisher();
dp.setAuthInfo(authToken.getAuthInfo());
dp.getPublisherId().addAll(listPublisherId);
return
dp;
}
public
static
DeletePublisher GetDeletePublisher(Publisher publisher, AuthToken authToken) throws
Exception
{
List<String> listPublisherId = new
ArrayList<String>();
listPublisherId.add(publisher.getAuthorizedName());
return
GetDeletePublisher(listPublisherId, authToken);
}
public
static
DeletePublisher GetDeletePublisher(String publisherId, AuthToken authToken) throws
Exception
{
List<String> listPublisherId = new
ArrayList<String>();
listPublisherId.add(publisherId);
return
GetDeletePublisher(listPublisherId, authToken);
}
public
static
Publisher MakePublisherSimple(String authorizedName, String publisherName,
String isAdmin, String isEnabled)
{
return
MakePublisher(authorizedName, publisherName, isAdmin, isEnabled, isAdmin,
null
, null
, null
, null
);
}
public
static
Publisher MakePublisher(String authorizedName, String publisherName,
String isAdmin, String isEnabled, String emailAddress,
Integer maxBindingsPerService, Integer maxBusiness,
Integer maxServicePerBusiness, Integer maxTModels)
{
Publisher p = new
Publisher();
p.setAuthorizedName(authorizedName);
p.setPublisherName(publisherName);
p.setIsAdmin(isAdmin);
p.setIsEnabled(isEnabled);
p.setEmailAddress(emailAddress);
p.setMaxBindingsPerService(maxBindingsPerService);
p.setMaxBusinesses(maxBusiness);
p.setMaxServicePerBusiness(maxServicePerBusiness);
p.setMaxTModels(maxTModels);
return
p;
}
//--------------------------- end of Publisher ---------------------------
}