All Downloads are FREE. Search and download functionalities are using the official Maven repository.

libraries.Core.pec Maven / Gradle / Ivy

The newest version!
define Callback as abstract method
define AnyCallback as abstract method receiving Any value
define BooleanCallback as abstract method receiving Boolean value
define IntegerCallback as abstract method receiving Integer value
define DecimalCallback as abstract method receiving Decimal value
define TextCallback as abstract method receiving Text value
define DateCallback as abstract method receiving Decimal value
define TimeCallback as abstract method receiving Time value
define DateTimeCallback as abstract method receiving DateTime value
define PeriodCallback as abstract method receiving Period value
define UuidCallback as abstract method receiving Uuid value
define DocumentCallback as abstract method receiving Document value
define Any as native category with attributes id and text, and bindings:

	define category bindings as:
		Java: prompto.intrinsic.PromptoAny
		C#: prompto.value.AnyValue
		Python2: AnyValue from module: prompto.value.AnyValue
		Python3: AnyValue from module: prompto.value.AnyValue
		JavaScript: AnyValue from module: prompto/intrinsic/AnyValue.js

and methods: 

	define id as getter doing:
		Java: return System.identityHashCode(this);
		C#: return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this);
		Python2: return id(self)
		Python3: return id(self)
		JavaScript: return this.id;
	
	define text as getter doing:
		Java: return this.toString();
		C#: return this.ToString();
		Python2: return str(self)
		Python3: return str(self)
		JavaScript: return this.toString();

define Attribute as native category with attribute name, and bindings:

	define category bindings as:
		Java: prompto.declaration.AttributeDeclaration
		C#: prompto.declaration.AttributeDeclaration
		Python2: AttributeDeclaration from module: prompto.declaration.AttributeDeclaration
		Python3: AttributeDeclaration from module: prompto.declaration.AttributeDeclaration
		JavaScript: AttributeDeclaration from module: prompto/declaration/AttributeDeclaration.js

define findAttribute as native method receiving name returning Attribute doing:
	Java: return $context.findAttribute(name);
	C#: return $context.findAttribute(name);
	Python2: return $context.findAttribute(name)
	Python3: return $context.findAttribute(name)
	JavaScript: return $context.findAttribute(name);

define getAllAttributes as native method returning Attribute[] doing:
	Java: return $context.getAllAttributes();
	C#: return $context.getAllAttributes();
	Python2: return $context.getAllAttributes()
	Python3: return $context.getAllAttributes()
	JavaScript: return $context.getAllAttributes();

define "findAttribute id" as test method doing:
	a = findAttribute "id"
and verifying: 
	a is an Attribute
	a.name = "id"

define "findAttribute name" as test method doing:
	a = findAttribute "name"
and verifying: 
	a is an Attribute
	a.name = "name" 

define "findAttribute text" as test method doing: 
	a = findAttribute "text"
and verifying: 
	a is an Attribute
	a.name = "text"

define "at least 3 items getAllAttributes" as test method doing:
	l = getAllAttributes 
and verifying: 
	l is an Attribute[]
	l.count >= 3

// runtime reference of any object
define id as Integer attribute
// database reference of stored object
define dbId as storable DbId attribute
// any object has a text attribute, used for display 
define text as storable Text attribute with value and words index
// many objects have a name, it is not unique 
define name as storable Text attribute with key and value index
// many objects have a description, it is not unique 
define description as storable Text attribute with words index
// many objects have an image, it is not unique 
define image as storable Image attribute
// many events have a timeStamp
define timeStamp as storable DateTime attribute
// urls, files and fragments have a path
define path as storable Text attribute
// external text sources have an encoding such as "UTF-8"
define encoding as storable Text attribute
// many systems require a login
define login as storable Text attribute with key and value index
// many systems require a password
define password as Text attribute
// users typically have an email  
define email as storable Text attribute with value index

define isAuditEnabled as native method returning Boolean doing:
	Java: return $store.isAuditEnabled();
	C#: return $store.IsAuditEnabled();
	Python2: return $store.isAuditEnabled()
	Python3: return $store.isAuditEnabled()
	JavaScript: return $store.isAuditEnabled();

define fetchLatestAuditMetadataId as native method receiving DbId dbId returning DbId doing:
	Java: return $store.fetchLatestAuditMetadataId(dbId);
	C#: return $store.FetchLatestAuditMetadataId(dbId);
	Python2: return $store.fetchLatestAuditMetadataId(dbId)
	Python3: return $store.fetchLatestAuditMetadataId(dbId)
	JavaScript: return $store.fetchLatestAuditMetadataId(dbId);

define fetchAllAuditMetadataIds as native method receiving DbId dbId returning DbId[] doing:
	Java: return $store.fetchAllAuditMetadataIds(dbId);
	C#: return $store.FetchAllAuditMetadataIds(dbId);
	Python2: return $store.fetchAllAuditMetadataIds(dbId)
	Python3: return $store.fetchAllAuditMetadataIds(dbId)
	JavaScript: return $store.fetchAllAuditMetadataIds(dbId);

define fetchAuditMetadata as native method receiving DbId dbId returning Document doing:
	Java: return $store.fetchAuditMetadataAsDocument(dbId);
	C#: return $store.FetchAuditMetadataAsDocument(dbId);
	Python2: return $store.fetchAuditMetadataAsDocument(dbId)
	Python3: return $store.fetchAuditMetadataAsDocument(dbId)
	JavaScript: return $store.fetchAuditMetadataAsDocument(dbId);

define fetchDbIdsAffectedByAuditMetadataId as native method receiving DbId dbId returning DbId[] doing:
	Java: return $store.fetchDbIdsAffectedByAuditMetadataId(dbId);
	C#: return $store.fetchDbIdsAffectedByAuditMetadataId(dbId);
	Python2: return $store.fetchDbIdsAffectedByAuditMetadataId(dbId)
	Python3: return $store.fetchDbIdsAffectedByAuditMetadataId(dbId)
	JavaScript: return $store.fetchDbIdsAffectedByAuditMetadataId(dbId);

define fetchLatestAuditRecord as native method receiving DbId dbId returning Document doing:
	Java: return $store.fetchLatestAuditRecordAsDocument(dbId);
	C#: return $store.FetchLatestAuditRecordAsDocument(dbId);
	Python2: return $store.fetchLatestAuditRecordAsDocument(dbId)
	Python3: return $store.fetchLatestAuditRecordAsDocument(dbId)
	JavaScript: return $store.fetchLatestAuditRecordAsDocument(dbId);

define fetchAllAuditRecords as native method receiving DbId dbId returning Document[] doing:
	Java: return $store.fetchAllAuditRecordsAsDocuments(dbId);
	C#: return $store.FetchAllAuditRecordsAsDocuments(dbId);
	Python2: return $store.fetchAllAuditRecordsAsDocuments(dbId)
	Python3: return $store.fetchAllAuditRecordsAsDocuments(dbId)
	JavaScript: return $store.fetchAllAuditRecordsAsDocuments(dbId);

define fetchAuditRecordsMatching as native method receiving Document auditPredicates = nothing and Document instancePredicates = nothing returning Document[] doing:
	Java: return $store.fetchAuditRecordsMatchingAsDocuments(auditPredicates, instancePredicates);
	C#: return $store.FetchAuditRecordsMatchingAsDocuments(auditPredicates, instancePredicates);
	Python2: return $store.fetchAuditRecordsMatchingAsDocuments(auditPredicates, instancePredicates)
	Python3: return $store.fetchAuditRecordsMatchingAsDocuments(auditPredicates, instancePredicates)
	JavaScript: return $store.fetchAuditRecordsMatchingAsDocuments(auditPredicates, instancePredicates);

define deleteAuditRecord as native method receiving DbId dbId returning Boolean doing:
	Java: return $store.deleteAuditRecord(dbId);
	C#: return $store.DeleteAuditRecord(dbId);
	Python2: return $store.deleteAuditRecord(dbId)
	Python3: return $store.deleteAuditRecord(dbId)
	JavaScript: return $store.deleteAuditRecord(dbId);

define deleteAuditMetadata as native method receiving DbId dbId returning Boolean doing:
	Java: return $store.deleteAuditMetadata(dbId);
	C#: return $store.DeleteAuditMetadata(dbId);
	Python2: return $store.deleteAuditMetadata(dbId)
	Python3: return $store.deleteAuditMetadata(dbId)
	JavaScript: return $store.deleteAuditMetadata(dbId);
define Category as native category with attribute name, and bindings:

	define category bindings as:
		Java: prompto.declaration.CategoryDeclaration
		C#: prompto.declaration.CategoryDeclaration
		Python2: CategoryDeclaration from module: prompto.declaration.CategoryDeclaration
		Python3: CategoryDeclaration from module: prompto.declaration.CategoryDeclaration
		JavaScript: CategoryDeclaration from module: prompto/declaration/CategoryDeclaration.js

define getCurrentCloud as native method returning Text doing:
	Java: return prompto.cloud.Cloud.current().name();

define getApplicationConfiguration as native method returning Document doing:
	Java: return prompto.runtime.Standalone.getApplicationConfiguration();
define Error as enumerated category with attributes name and text, and symbols:
	DIVIDE_BY_ZERO with "Divide by zero!" as text
	INDEX_OUT_OF_RANGE with "Index out of range!" as text
	NULL_REFERENCE with "Null reference!" as text
	NOT_MUTABLE with "Not a mutable object!" as text
	NOT_STORABLE with "Not a storable object!" as text
	AUDIT_DISABLED with "Audit is disabled!" as text
	READ_WRITE with "Read/write failed!" as text

define DecimalConstant as enumerated Decimal with symbols:
	PI with 3.14159265358979323846 as value
	E with 2.7182818284590452354 as value

define parseInteger as native method receiving Text text returning Integer doing:
	Java: return Long.parseLong(text);
	C#: return System.Int64.Parse(text);
	Python2: return int(text)
	Python3: return int(text)
	JavaScript: return parseInt(text);


define parseDecimal as native method receiving Text text returning Decimal doing:
	Java: return Double.parseDouble(text);
	C#: return System.Double.Parse(text, System.Globalization.CultureInfo.InvariantCulture);
	Python2: return float(text)
	Python3: return float(text)
	JavaScript: return parseFloat(text);


define parseDate as native method receiving Text text returning Date doing:
	Java: return prompto.intrinsic.PromptoDate.parse(text);
	C#: return prompto.value.DateValue.Parse(text);
	Python2: return DateValue.Parse(text) from module: prompto.value.DateValue
	Python3: return DateValue.Parse(text) from module: prompto.value.DateValue
	JavaScript: return LocalDate.parse(text); from module: prompto/intrinsic/LocalDate.js


define parseTime as native method receiving Text text returning Time doing:
	Java: return prompto.intrinsic.PromptoTime.parse(text);
	C#: return prompto.value.TimeValue.Parse(text);
	Python2: return TimeValue.Parse(text) from module: prompto.value.TimeValue
	Python3: return TimeValue.Parse(text) from module: prompto.value.TimeValue
	JavaScript: return LocalTime.parse(text); from module: prompto/intrinsic/LocalTime.js


define parseDateTime as native method receiving Text text returning DateTime doing:
	Java: return prompto.intrinsic.PromptoDateTime.parse(text);
	C#: return prompto.value.DateTimeValue.Parse(text);
	Python2: return DateTimeValue.Parse(text) from module: prompto.value.DateTimeValue
	Python3: return DateTimeValue.Parse(text) from module: prompto.value.DateTimeValue
	JavaScript: return DateTime.parse(text); from module: prompto/intrinsic/DateTime.js


define parseUuid as native method receiving Text text returning Uuid doing:
	Java: return java.util.UUID.fromString(text);
	C#: return System.Guid.Parse(text);
	Python2: return UUID(text) from module: uuid
	Python3: return UUID(text) from module: uuid
	JavaScript: return UUID.fromString(text); from module: prompto/intrinsic/UUID.js


define parseVersion as native method receiving Text text returning Version doing:
	Java: return prompto.intrinsic.PromptoVersion.parse(text);
	C#: return prompto.value.VersionValue.Parse(text);
	Python2: return VersionValue.Parse(text) from module: prompto.value.VersionValue
	Python3: return VersionValue.Parse(text) from module: prompto.value.VersionValue
	JavaScript: return Version.parse(text); from module: prompto/intrinsic/Version.js


define parsePeriod as native method receiving Text text returning Period doing:
	Java: return prompto.intrinsic.PromptoPeriod.parse(text);
	C#: return prompto.value.PeriodValue.Parse(text);
	Python2: return PeriodValue.Parse(text) from module: prompto.value.PeriodValue
	Python3: return PeriodValue.Parse(text) from module: prompto.value.PeriodValue
	JavaScript: return Period.parse(text); from module: prompto/intrinsic/Period.js


define "parses Integer" as test method doing:
	i = parseInteger "123"
and verifying:
	i = 123

define "parses Integer with leading 0" as test method doing:
	i = parseInteger "0123"
and verifying:
	i = 123

define "parses Decimal" as test method doing:
	i = parseDecimal "123.45"
and verifying:
	i = 123.45

define "parses Date" as test method doing:
	d = parseDate "2018-02-17"
and verifying:
	d = '2018-02-17'

define "parses Time" as test method doing:
	t = parseTime "16:15:18"
and verifying:
	t = '16:15:18'

define "parses DateTime" as test method doing:
	dt = parseDateTime "2018-02-17T16:15:18"
and verifying:
	dt = '2018-02-17T16:15:18'

define "parses Uuid" as test method doing:
	u = parseUuid "11223344-aabb-ccdd-eeff-112233445566"
and verifying:
	u = '11223344-aabb-ccdd-eeff-112233445566'

define "parses Version" as test method doing:
	v = parseVersion "v1.2.3"
and verifying:
	v = 'v1.2.3'

define "parses Period" as test method doing:
	p = parsePeriod "PT1S"
and verifying:
	p = 'PT1S'

define now as native method returning DateTime doing:
	Java: return prompto.intrinsic.PromptoDateTime.now();
	C#: return System.DateTimeOffset.Now;
	Python2: return datetime.utcnow() from module: datetime
	Python3: return datetime.utcnow() from module: datetime
	JavaScript: return DateTime.now(); from module: prompto/intrinsic/DateTime.js

define "now is a DateTime" as test method doing: 
	a = now
and verifying: 
	a is a DateTime 

define today as method returning Date doing:
	return now.date

define "today is a Date" as test method doing: 
	a = today
and verifying: 
	a is a Date 

// waits for n milliseconds (consuming all CPU in JavaScript)
define sleep as native method receiving Integer millis doing:
	Java: java.lang.Thread.sleep(millis);
	C#: prompto.utils.Utils.Sleep(millis);
	Python2: sleep(millis) from module: prompto.utils.Utils
	Python3: sleep(millis) from module: prompto.utils.Utils
	JavaScript: sleep(millis); from module: prompto/utils/Utils.js

define "sleeps for 1 second" as test method doing:
	start = now
	sleep 1000
	end = now
and verifying: 
	end >= start + 'PT1S'

define scheduleJob as native method receiving Callback callback, DateTime executeAt, Period repeatEvery = Nothing and Text jobName = Nothing returning Integer doing:
	Java: return prompto.runtime.Scheduler.schedule(callback, executeAt, repeatEvery, jobName);
	C#: return prompto.runtime.Scheduler.schedule(callback, executeAt, repeatEvery, jobName);
	Python2: return Scheduler.schedule(callback, executeAt, repeatEvery, jobName) from module: prompto.runtime.Scheduler
	Python3: return Scheduler.schedule(callback, executeAt, repeatEvery, jobName) from module: prompto.runtime.Scheduler
	JavaScript: return Scheduler.schedule(callback, executeAt, repeatEvery, jobName); from module: prompto/runtime/Scheduler.js

define cancelJob as native method receiving Integer jobId doing:
	Java: prompto.runtime.Scheduler.cancel(jobId);
	C#: prompto.runtime.Scheduler.cancel(jobId);
	Python2: Scheduler.cancel(jobId) from module: prompto.runtime.Scheduler
	Python3: Scheduler.cancel(jobId) from module: prompto.runtime.Scheduler
	JavaScript: Scheduler.cancel(jobId); from module: prompto/runtime/Scheduler.js

// returns a random UUID as defined by http://www.ietf.org/rfc/rfc4122.txt
define randomUuid as native method returning Uuid doing:
	Java: return java.util.UUID.randomUUID();
	C#: return System.Guid.NewGuid();
	Python2: return uuid4() from module: uuid
	Python3: return uuid4() from module: uuid
	JavaScript: return UUID.create(); from module: prompto/intrinsic/UUID.js

define "randomUuid is not null" as test method doing:
	uuid = randomUuid
and verifying: 
	uuid is not Nothing


define isServer as native method returning Boolean doing:
	Java: return $context.isServer();
	C#: return false;
	Python2: return False
	Python3: return False
	JavaScript: return false;


define fetchTextResource as native method receiving path returning Text doing:
	Java: return $context.fetchTextResource(path);
	C#: return $context.fetchTextResource(path);
	Python2: return $context.fetchTextResource(path)
	Python3: return $context.fetchTextResource(path)
	JavaScript: return $context.fetchTextResource(path);


define fetchBinaryResource as native method receiving path returning Blob doing:
	Java: return $context.fetchBinaryResource(path);
	C#: return $context.fetchBinaryResource(path);
	Python2: return $context.fetchBinaryResource(path)
	Python3: return $context.fetchBinaryResource(path)
	JavaScript: return $context.fetchBinaryResource(path);
 

define nextSequenceValue as native method receiving Text name returning Integer doing:
	Java: return $store.nextSequenceValue(name);
	C#: return $store.NextSequenceValue(name);
	Python2: return $store.nextSequenceValue(name)
	Python3: return $store.nextSequenceValue(name)
	JavaScript: return $store.nextSequenceValue(name);


define "nextSequenceValue increases" as test method doing:
	v1 = nextSequenceValue "BIG"
	v2 = nextSequenceValue "BIG"
	v3 = nextSequenceValue "BIG"
and verifying: 
	v1 = 1
	v2 = 2
	v3 = 3




© 2015 - 2025 Weber Informatics LLC | Privacy Policy